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).

RG generator and validator (SSP-SP format)

The RG (Registro Geral) is the identity card number issued by each Brazilian state. Generate fictitious RGs in the São Paulo format with a computed check digit, and validate whole lists, to test ID fields, masks and validation rules without real personal data.

—

Up to 1000 items at once. Everything is generated in your browser.

How to use

  1. On the generator tab, tick or untick With mask (punctuation) to get 24.678.135-X or 24678135X.
  2. Click Generate, then Copy to put the number on your clipboard.
  3. To seed a staging database, set the Quantity (1–1000) and use Export CSV, Export JSON or Export SQL.
  4. On the Validate tab, paste one or many RGs, one per line. Dots, hyphens and spaces are ignored, and a lowercase x is accepted.
  5. Each line shows whether the number matches the SSP-SP pattern, or why it failed: wrong length or characters, or a wrong check digit.

How it works

Why only the São Paulo format

Brazil has no national RG numbering. Each of the 27 states issues identity cards through its own identification institute; in São Paulo that is IIRGD, part of the state Civil Police, with service desks at Poupatempo. Lengths, layouts and rules differ by state, and most states publish no check-digit formula at all. That is why this tool supports only the SSP-SP pattern, the one that is widely documented and used by commercial software. RGs from other states are neither generated nor validated here, and a genuine out-of-state RG may fail the check.

To be clear: we found no official SSP-SP or Poupatempo page that publishes the calculation. The rule below is the one used by open-source validators, and it is exactly what this page’s code implements.

Format and calculation

The number has 8 base digits plus 1 check character, written ##.###.###-#. The check character is a digit or the letter X.

  1. Multiply the 8 base digits, left to right, by the weights 2, 3, 4, 5, 6, 7, 8 and 9.
  2. Add the products and take the remainder modulo 11.
  3. Compute 11 − remainder. A result of 10 becomes X; 11 (remainder 0) becomes 0; anything else is used as is.

The generator also skips bases made of a single repeated digit and bases starting with zero.

Worked example: 24.678.135-?

Products: 2×2 + 4×3 + 6×4 + 7×5 + 8×6 + 1×7 + 3×8 + 5×9 = 4 + 12 + 24 + 35 + 48 + 7 + 24 + 45 = 199.

199 mod 11 = 1 (11 × 18 = 198). 11 − 1 = 10, so the check character is X.

Result: 24.678.135-X, or 24678135X unmasked.

What about the new national ID card?

The Carteira de Identidade Nacional (CIN), which is gradually replacing the RG, uses the CPF taxpayer number as its single ID. To test that field, use the CPF generator. The numbers on this page remain useful for legacy systems that store São Paulo RGs.

FAQ

Why does an RG from another state show as invalid?

Because the validator only knows the SSP-SP pattern. Each state defines its own numbering and almost none publish a check-digit rule, so RGs from other states cannot be checked reliably. An invalid result for a non-São Paulo RG does not mean the document is fake.

What does the trailing X mean?

It is the check character when 11 − remainder equals 10; since only one character fits, the letter X is used. If your database stores RGs as integers you will lose that case, so use a text column such as VARCHAR(9) without the mask.

Does a valid result mean the RG exists?

No. The tool only checks length, characters and the check digit using the rule above. Whether an RG was ever issued, who holds it or whether it is still valid can only be answered by the state identification institute, which this tool does not query.

Can I use these RGs for real sign-ups?

No. They are fictitious and meant for automated tests, staging environments, demos and fixtures. Using them to identify yourself on real services or to get around identity checks is improper and may be a crime.

Does SSP-SP publish this formula?

We could not find any official SSP-SP, IIRGD or Poupatempo publication of the calculation. The modulo 11 rule with weights 2 to 9 was documented by the developer community and is widely used. If your project needs formal assurance, confirm with the issuing agency.

Sources

Related tools

Updated 2026-11-13 · Rafael Lima