Codice Fiscale generator and validator

Generate and validate a Codice Fiscale for tests, with the check digit algorithm shown with a worked example.

loading Codice Fiscale generator and validator
About this tool

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:

PositionCharacterPosition typeValue used
1Qodd6
2Xeven23
3Zodd23
4Xeven23
5Godd15
6Yeven24
74odd9
82even2
9Sodd12
104even4
113odd7
12Zeven25
136odd15
140even0
152odd5

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 maskValidator
QXZXGY42S43Z602Lvalid
WXRSBA94S60F839Hvalid
DTLJNM90D69G273Vvalid
QHPVNX71R63C351Dvalid
LHRSNQ76C09L736Mvalid

How the validator answers

The same first example, one with a changed ending and one truncated, checked by the validator:

ValueResultReason
QXZXGY42S43Z602Lvalid-
QXZXGY42S43Z602Minvalidthe check digit should be L
QXZXGY42S43Z60invalidneeds 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.

Report a problem