Format-preserving masking: why masked data must still look real
Format-preserving masking replaces each value with a different value of the same shape. Digits stay digits, letters stay letters, and the length does not change. The application, its validation and its tests still work on the masked data, and that is why developers want production data.
What goes wrong when masked data does not look real?
Take one card number in production, 4871 8033 4018 7801, and mask it four ways.
| Mask | It becomes | What happens |
|---|---|---|
| Stars | **** **** **** **** | Validation rejects it. |
| A hash | 9c1e47ab02f6d81e… 64 characters | It does not fit a column that holds 19 characters. |
| One fixed value | 0000 0000 0000 0000 | Every row is the same, so tests stop finding problems. |
| Same format | 4372 6167 5136 1341 | It passes the card check, fits the column, and every value is different. |
When the masked copy is no use to them, developers ask for access to production or keep an unmasked copy.
What does a mask have to keep?
- Joins still match
- A foreign key column is masked the same way as the column it references.
- One value, one result
- The same value becomes the same masked value in every table, so a customer number lines up across the database.
- Unique stays unique
- Washery checks the policy against your keys before a run and refuses one that would break them.
- Primary keys are kept
- A key is only masked when the key itself holds sensitive data.
- Types and lengths do not change
- Every column keeps its type and its length, so your schema and your code work as they are.
- No way back to the original
- Same-format values use a key made for each run and never stored, so a masked value can’t be traced back.
What does it look like?
Examples show the kind of value a method writes. Every value here is made up.
| Kind of data | In production, and in the masked copy |
|---|---|
| Names | Mia ChenbecomesElla Novak |
| Phone numbers | 0412 880 316becomes0413 927 506 |
| Tax and government identifiers | 628 194 821becomes252 760 189 |
| Card numbers | 4871 8033 4018 7801becomes4372 6167 5136 1341 |
| Bank account details | 063-109 1048 2217becomes418-552 7306 9941 |
| Dates of birth | 1991-07-22becomes1991-06-09 |
Is it the same as format-preserving encryption?
No. Format-preserving encryption can be reversed by anyone who has the key. Data for development and testing should never be reversible, so a mask uses a key that is thrown away after the run, or no key at all.
How Washery does it
Washery proposes a masking method for every column that holds sensitive data, and each method keeps the data usable for testing. Names become made-up names. Identifiers get the Same format method, which keeps the layout and the check digit.

Same-format values use a key made for each run and never kept, so a masked value cannot be turned back into the original. How data is masked shows every method.
When is it not the right approach?
- Free text. Notes and comments have no format to keep. Redact them, because people type sensitive data into them.
- Passwords, keys and tokens. Clear them. A value that looks like a working secret is no use in a test database.