# Character Substitution

Performs a random character replacement that preserves formatting (spaces, capitalization, and punctuation).

Characters are replaced with other characters from within the same Unicode Block. A given source character is always mapped to the same destination character. For example, `M` might always map to `V`.

For example, for the following input string:

`Miami Store #162`

The output would be something like:

`Vgkjg Gmlvf #681`

Note that for a numeric column, when a generated number starts with a 0, the starting 0 is removed. This could result in matching output values in different columns. For example, one column is changed to 113 and the other to 0113, which also becomes 113.

Character Substitution is similar to [Character Scramble](/app/generation/generators/generator-reference/character-scramble.md), with a couple of key differences. Because Character Substitution always maps the same source character to the same destination character, it is always consistent. It also can be used for unique columns.

In Character Scramble, the character mapping is random, which makes Character Scramble slightly more secure. However, Character Scramble cannot be used for unique columns.

## Characteristics <a href="#character-substitution-characteristics" id="character-substitution-characteristics"></a>

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><strong>Consistency</strong></td><td valign="top">This generator is implicitly self-consistent. You do not specify whether the generator is consistent.<br><br>Every occurrence of a character always maps to the same substitute character.<br><br>Because of this, it can be used to preserve a join between two text columns, such as a join on a name or email.</td></tr><tr><td valign="top"><strong>Linking</strong></td><td valign="top">No, cannot be linked.</td></tr><tr><td valign="top"><strong>Differential privacy</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Data-free</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Allowed for primary keys</strong></td><td valign="top">Yes</td></tr><tr><td valign="top"><strong>Allowed for unique columns</strong></td><td valign="top">Yes</td></tr><tr><td valign="top"><strong>Uses format-preserving encryption (FPE)</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Privacy ranking</strong></td><td valign="top">4</td></tr><tr><td valign="top"><strong>Generator ID (for the API)</strong></td><td valign="top"><a href="/pages/fy8n3fsQgTSDMuuKuSIt"><code>StringMaskGenerator</code></a></td></tr></tbody></table>

## How to configure <a href="#character-substitution-configure" id="character-substitution-configure"></a>

If [Structural data encryption](/app/generation/generators-assign-config/generators-data-encryption-config.md) is enabled, then to use it for this column, in the advanced options section, toggle **Use data encryption process** to the on position.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/generation/generators/generator-reference/character-substitution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
