Format Preserving masking policy (predefined)

The predefined Format Preserving policy masks a selected column while preserving the structural format of the input value, including the positions of non-alphanumeric characters.

The Format Preserving policy replaces alphabetic characters with generated alphabetic characters and numeric characters with generated numeric characters. Non-alphanumeric characters such as dashes, spaces, and punctuation are preserved verbatim in their original positions. You can control the output length, the case of output letters, and optionally remove specific characters from the input before masking.

Configuration options

Use the following options to configure the Format Preserving policy.

Length (required)

Sets the number of characters in the masked output.

Table 1. Length values and behavior
Value Behavior
0 Preserves the source length. The output has the same number of characters as the input (after any Char to Omit processing).
N < input length Truncates. Only the first N characters of the input are masked and returned.
N > input length Pads. The input is masked in full, then additional generated characters are appended until the output reaches length N.
Note: The length guarantee does not always hold for numeric column types. If the masked result begins with leading zeros, those zeros are dropped when written to a numeric target, reducing the effective output length. For example, a masked value of 05678 written to a numeric column becomes 5678. When padding characters are added under Case Type Normal, the padding letters are lowercase.
Char to Omit (optional)

A string of characters to remove from the input before masking. Every individual character present in this string is stripped from the source value — all occurrences, regardless of position or order — before the masked value is generated.

Note: Char to Omit is case-sensitive and removes individual characters, not substrings. The value "test" removes every t, every e, and every s from the input, not just the exact sequence "test".
Case Type (required)

Controls the case of alphabetic characters in the masked output.

Table 2. Case Type options
Option Behavior
Normal Output letters match the case pattern of the input. Uppercase input positions produce uppercase output, lowercase produce lowercase.
Upper All output letters are uppercase, regardless of input case.
Lower All output letters are lowercase, regardless of input case.

Processing order

When both Char to Omit and Length are configured, operations are applied in the following order:

  1. Char to Omit — specified characters are stripped from the input.
  2. Length — the truncation or padding target is applied to the stripped input.
  3. Masking — the processed input is masked.
  4. Case Type — output case is applied to the masked result.

API configuration (policy_metadata)

Use the following keys to configure the Format Preserving policy through the API.

Table 3. Format Preserving policy_metadata fields
Key UI field Type Description
length Length String "0" preserves source length; "N" truncates or pads to N characters.
omit Char to Omit String Characters to remove from the input before masking. Use "" for none.
case Case Type String
  • "normal"
  • "upper"
  • "lower"
{
  "case": "normal",
  "length": "0",
  "omit": ""
}

Known limitations

The Email policy has the following limitations.

Length is not guaranteed for numeric column types
When the masked output begins with leading zeros and the target column is a numeric type, those zeros are dropped on write, reducing the effective output length below the configured value.
Char to Omit is case-sensitive
Only the exact characters specified are removed. Lowercase "test" removes t, e, s but does not remove uppercase T, E, S. Include both cases to remove a letter in both forms.
Char to Omit removes individual characters, not substrings
The Char to Omit value is treated as a set of individual characters. The value "test" removes every t, e, and s — not just the literal sequence "test".
Padding letters under Normal case are always lowercase
When the configured Length exceeds the input length and Case Type is Normal, the additional padding characters are lowercase. A padded output under Normal case may have a different case distribution than the input.
Non-alphanumeric characters are always preserved verbatim
Dashes, spaces, and other non-alphanumeric characters in the input are never masked. They are passed through unchanged to the output at their original positions. If these characters contain sensitive information, this policy alone is insufficient.