Test data for Brazilian software
EN
Fictitious data for software testing. Using fake documents for fraud is a crime in Brazil (Penal Code, arts. 297–299, 307).

Brazilian document formatter

Paste a list of Brazilian IDs, postal codes (CEP), phone numbers or other values and add or remove their standard punctuation in one go, with automatic type detection. Handy for cleaning spreadsheets, preparing imports and checking form input masks.

Action

How to use

  1. Paste the values into the input box, one per line (up to 1000 lines). They can be masked, unmasked or mixed.
  2. Pick the document type or leave Detect automatically on so each line is identified by its length.
  3. Choose the mode: Add mask applies the standard punctuation, Remove mask keeps only digits (plus letters for alphanumeric CNPJ, RG with X and plates).
  4. Click Format. Output keeps the input order, blank lines included, so you can paste it straight back into a spreadsheet column.
  5. Lines that match no format, or whose length does not fit the chosen type, come back unchanged and flagged. Use Copy to grab the result.

How it works

Supported masks

TypeLengthMaskExample
CPF (individual taxpayer ID)11###.###.###-##168.079.072-22
CNPJ (company ID, numeric or alphanumeric)14##.###.###/####-##91.302.439/0001-24, 12.ABC.345/01DE-35
CEP (postal code)8#####-###30581-873
Landline10(##) ####-####(31) 3333-4444
Mobile11(##) #####-####(11) 95550-1234
PIS/PASEP/NIT (social security)11###.#####.##-#512.88726.00-0
Título (voter ID)12#### #### ####2199 5853 1007
RG (SSP-SP pattern)9##.###.###-#82.372.952-7, 82.372.952-X
Old licence plate7AAA-####ABC-1234
Mercosur plate7no punctuationBRA2E19
Civil certificate (matrícula)32blocks 6·2·2·4·1·5·3·7·2177837 01 55 2021 2 00588 090 0130141 17
Bank boleto47typeable line, 5 fields34192.90055 62293.552790 14298.128241 5 16500000046404
Utility/tax boleto484 blocks of 11 + check digit85830000048-3 00435589776-0 80626383599-5 16348829640-9
Card16#### #### #### ####6062 8233 7916 7288

Letters are upper-cased. 15-digit cards (Amex) are not covered and come back unchanged.

How automatic detection works

If a line contains letters it is treated as an alphanumeric CNPJ (14 characters ending in 2 digits), a plate or an RG ending in X. For digits only, the length decides: 8 = CEP, 9 = RG-SP, 10 = landline, 12 = voter ID, 14 = CNPJ, 16 = card, 32 = certificate, 47 or 48 = boleto. Eleven digits could be a CPF, a PIS or a mobile number, so the tie is broken in this order:

  1. if the check digits work as a CPF, it is a CPF;
  2. otherwise, if they work as a PIS, it is a PIS;
  3. otherwise, if the 3rd digit is 9 (the first digit of a mobile number after the area code), it is a phone;
  4. otherwise the CPF mask is applied.

Example with four 11-digit lines: 16807907222 passes as a CPF → 168.079.072-22; 51288726000 is not a CPF but is a valid PIS → 512.88726.00-0; 11955501234 is neither and its 3rd digit is 9 → (11) 95550-1234; 21812345678 matches nothing and its 3rd digit is 8 → 218.123.456-78. Because a mobile number can happen to have valid CPF or PIS check digits, pick the type manually when a column holds a single kind of value.

The formatter does not validate

It only touches punctuation and never checks or fixes check digits. 218.123.456-78 above is formatted but is not a valid CPF. To check values, use the CPF validator, the CNPJ validator or the boleto validator.

Tips for JS and SQL

  • Store documents unmasked and format them only for display. Use text columns (CHAR(11), VARCHAR(14)), never integers: leading zeros disappear and the new CNPJ contains letters.
  • In JavaScript: v.replace(/D/g, '') for CPF and CEP; v.toUpperCase().replace(/[^0-9A-Z]/g, '') for the alphanumeric CNPJ.
  • To clean an existing column: REGEXP_REPLACE(cpf, '[^0-9]', '', 'g') in PostgreSQL or REGEXP_REPLACE(cpf, '[^0-9]', '') in MySQL 8.

FAQ

Does the formatter fix a wrong CPF or CNPJ?

No. It only adds or removes dots, slashes, hyphens, spaces and parentheses. A number with a wrong check digit comes out nicely formatted but still wrong. To know whether a value is valid, paste the same list into the Validate tab of the matching tool, which accepts one value per line.

Why was a mobile number formatted as a CPF or PIS?

With 11 digits, automatic detection tests the CPF and PIS check digits first and only then looks at the 3rd digit. Some phone numbers happen to satisfy the CPF or PIS arithmetic. When your list holds a single type, select it explicitly instead of Detect automatically.

Does my data leave the browser?

No. Formatting is done by JavaScript on the page itself, with no server round-trip, cookies or analytics. Even so, prefer fictitious or anonymised data when you are only testing masks, and handle real customer lists according to Brazil’s data protection law (LGPD).

Why did the Mercosur plate get no punctuation?

Because the Mercosur standard writes all seven characters together, as in BRA2E19. Only the old plate, three letters and four digits, gets a hyphen (ABC-1234). In Remove mask mode both come back without separators and upper-cased.

How do I format a phone with the +55 country code?

The formatter works on the national number: a 2-digit area code plus 8 (landline) or 9 (mobile) digits. If a line starts with +55, its length no longer fits and it is returned unchanged. Strip the country code first, or add it afterwards in whatever format your system expects.

Sources

Related tools

Updated 2026-11-13 · Rafael Lima