Codice Fiscale: what it is and how to test it
The Codice Fiscale is the Italian tax code of a person, issued by the Agenzia delle Entrate. It is not a random number: its 16 characters are derived from the surname, the given name, the birth date, the sex and the town of birth, with a control letter at the end. That is why a test code must be built, not just numbered.
For tests only. These numbers have a correct format and check digit but belong to no real person or account. Never use them to deceive, to open accounts or to bypass a check. The numbers on this page come from the same generator as the tool, with a fixed seed so that the examples do not change; the tool creates new ones at every click.
Structure of the number
16 characters: 3 letters from the surname, 3 from the given name, 2 digits of the birth year, a letter for the month (A B C D E H L M P R S T), 2 digits of the day (plus 40 for women), a place code of one letter and 3 digits, and the control letter. In case of homonyms ("omocodia") digits are replaced by the letters L M N P Q R S T U V.
The check digit, step by step
The control letter is calculated from the first 15 characters. Characters in odd positions (1st, 3rd, 5th...) are converted with a special table (for example A = 1, B = 0, C = 5), those in even positions keep their natural value (digits 0 to 9, letters A = 0 to Z = 25). The values are summed, the sum is divided by 26 and the remainder is turned into a letter (0 = A ... 25 = Z).
Worked example with QXZXGY42S43Z602L:
| Position | Character | Position type | Value used |
|---|---|---|---|
| 1 | Q | odd | 6 |
| 2 | X | even | 23 |
| 3 | Z | odd | 23 |
| 4 | X | even | 23 |
| 5 | G | odd | 15 |
| 6 | Y | even | 24 |
| 7 | 4 | odd | 9 |
| 8 | 2 | even | 2 |
| 9 | S | odd | 12 |
| 10 | 4 | even | 4 |
| 11 | 3 | odd | 7 |
| 12 | Z | even | 25 |
| 13 | 6 | odd | 15 |
| 14 | 0 | even | 0 |
| 15 | 2 | odd | 5 |
Sum = 193; 193 mod 26 = 11; letter number 11 of the alphabet (A = 0) is "L", the control character.
Valid examples
Five numbers generated by the tool with a fixed seed, each one accepted by its validator:
| Without mask | Validator |
|---|---|
QXZXGY42S43Z602L | valid |
WXRSBA94S60F839H | valid |
DTLJNM90D69G273V | valid |
QHPVNX71R63C351D | valid |
LHRSNQ76C09L736M | valid |
How the validator answers
The same first example, one with a changed ending and one truncated, checked by the validator:
| Value | Result | Reason |
|---|---|---|
QXZXGY42S43Z602L | valid | - |
QXZXGY42S43Z602M | invalid | the check digit should be L |
QXZXGY42S43Z60 | invalid | needs 16 characters |
Common mistakes
- Counting positions from 0 instead of 1 swaps the odd and even tables and always gives the wrong letter: the first character is position 1 (odd).
- A code with letters among the digits of year, day or place is not necessarily wrong: it can be an "omocodia" code, which the validator must convert back before reading the date.
Frequently asked questions
How is the day written for women in the Codice Fiscale?
The birth day plus 40: a woman born on the 5th has 45, a man has 05. That is how the code carries the sex.
Does the generated code match a real person?
The name and surname letters of a generated code come from a random sequence, not from a name, but by chance it can coincide with a real code. It is test data: use it only in test environments.
Can I use a Codice Fiscale number generated here in a real system?
No. A number such as QXZXGY42S43Z602L has a correct format and check, but nobody was issued it, and it may coincide with a real holder by chance. Use it in test environments, demos and automated tests that never leave your control.