# UnicodeNormalizer
[EN] Source: https://mastra.ai/reference/processors/unicode-normalizer

The `UnicodeNormalizer` is an **input processor** that normalizes Unicode text to ensure consistent formatting and remove potentially problematic characters before messages are sent to the language model. This processor helps maintain text quality by handling various Unicode representations, removing control characters, and standardizing whitespace formatting.

## Usage example

```typescript copy
import { UnicodeNormalizer } from "@mastra/core/processors";

const processor = new UnicodeNormalizer({
  stripControlChars: true,
  collapseWhitespace: true
});
```

## Constructor parameters

<PropertiesTable
  content={[
    {
      name: "options",
      type: "Options",
      description: "Configuration options for Unicode text normalization",
      isOptional: true,
    },
  ]}
/>

### Options

<PropertiesTable
  content={[
    {
      name: "stripControlChars",
      type: "boolean",
      description: "Whether to strip control characters. When enabled, removes control characters except \t, \n, \r",
      isOptional: true,
      default: "false",
    },
    {
      name: "preserveEmojis",
      type: "boolean",
      description: "Whether to preserve emojis. When disabled, emojis may be removed if they contain control characters",
      isOptional: true,
      default: "true",
    },
    {
      name: "collapseWhitespace",
      type: "boolean",
      description: "Whether to collapse consecutive whitespace. When enabled, multiple spaces/tabs/newlines are collapsed to single instances",
      isOptional: true,
      default: "true",
    },
    {
      name: "trim",
      type: "boolean",
      description: "Whether to trim leading and trailing whitespace",
      isOptional: true,
      default: "true",
    },
  ]}
/>

## Returns

<PropertiesTable
  content={[
    {
      name: "name",
      type: "string",
      description: "Processor name set to 'unicode-normalizer'",
      isOptional: false,
    },
    {
      name: "processInput",
      type: "(args: { messages: MastraMessageV2[]; abort: (reason?: string) => never }) => MastraMessageV2[]",
      description: "Processes input messages to normalize Unicode text",
      isOptional: false,
    },
  ]}
/>


## Extended usage example

```typescript title="src/mastra/agents/normalized-agent.ts" showLineNumbers copy
import { Agent } from "@mastra/core/agent";
import { UnicodeNormalizer } from "@mastra/core/processors";

export const agent = new Agent({
  name: "normalized-agent",
  instructions: "You are a helpful assistant",
  model: "openai/gpt-4o-mini",
  inputProcessors: [
    new UnicodeNormalizer({
      stripControlChars: true,
      preserveEmojis: true,
      collapseWhitespace: true,
      trim: true
    })
  ]
});
```


## Related

- [Guardrails](/docs/agents/guardrails)


---
title: "Reference: Reference: .chunk() | RAG"
description: Documentation for the chunk function in Mastra, which splits documents into smaller segments using various strategies.
---