Generator · Italian data

Italian Codice Fiscale

Endpoint GET /v1/it/codice-fiscale

What it covers

Returns a valid Italian Codice Fiscale with a correct check character. Constrain with `sex`, age/birth-date filters (year, month, and day are encoded), and the optional `surname`/`name` to encode. Contradictory combinations are rejected with a 400. Set `invalid=true` for a deliberately wrong check character.

The codice fiscale is Italy’s personal tax code: sixteen characters encoding a surname code, a name code, the birth year, month (as a letter), day (offset by 40 for women), a place-of-birth code, and a final check character. It is alphanumeric, not purely numeric — the check is over letters and digits alike.

How it’s calculated

The sixteenth character is a mod-26 check letter computed from the first fifteen, using separate odd- and even-position value tables.

Algorithm

  1. Number the first fifteen characters by 1-indexed position (character 1 is position 1, “odd”).
  2. For each odd-position character, look up its value in the ODD table; for each even-position character, look up its value in the EVEN table.
  3. In the EVEN table, digits map to their face value and letters map A=0…Z=25.
  4. The ODD table is a special scrambled table (e.g. 0→1, 1→0, 2→5, 9→21, A→1, B→0, …).
  5. Sum all fifteen values, take the sum modulo 26, and map 0→A … 25→Z. That letter is the check character.

Worked example

positions 1–15 of a codice fiscale, e.g. RSSMRA85T10

Position 1 (odd): R → ODD table value
Position 2 (even): S → EVEN table value (S = 18)
… alternate ODD/EVEN across all 15 characters …
sum = Σ(odd-table values at positions 1,3,5,…) + Σ(even-table values at positions 2,4,6,…)
check = sum mod 26
map check: 0 → A, 1 → B, …, 25 → Z

The resulting letter is appended as character 16. Because the odd table is deliberately scrambled, transposing two adjacent characters changes the sum — that’s what makes the check catch common typos.

Edge cases

  • The day field encodes sex: for women, 40 is added to the birth day, so a woman born on the 3rd carries day 43. The two-digit day therefore ranges 01–31 for men and 41–71 for women.
  • The month is a letter, not a number: A, B, C, D, E, H, L, M, P, R, S, T map to January…December (skipping letters that resemble digits).
  • The check character is a letter A–Z, never a digit — it is the only field computed from all fifteen preceding characters.

Gotchas

  • Odd and even positions use entirely different value tables, and “odd/even” is 1-indexed — the first character is an odd position. A validator that 0-indexes will swap the two tables and reject valid codes.
  • Homocodia: when two people would collide, digits in the omocodia positions are replaced with letters. This generator produces the base (non-omocodic) form.

Parameters

ParameterTypeDescription
atAgeintegerExact age in years at request time.
bornAfterstringpattern ^\d{4}(?:-\d{2}(?:-\d{2})?)?$Born after this date or fragment (YYYY, YYYY-MM, YYYY-MM-DD).
bornBeforestringpattern ^\d{4}(?:-\d{2}(?:-\d{2})?)?$Born before this date or fragment (YYYY, YYYY-MM, YYYY-MM-DD).
bornOnstringpattern ^\d{4}(?:-\d{2}(?:-\d{2})?)?$Born on a date or within a fragment: YYYY, YYYY-MM, or YYYY-MM-DD.
countinteger1–1000Number of records to return, 1–1000 (your plan may lower this). Omitted returns a single record; set it for a batch.
edgebooleanRestrict output to edge-case values.
extremebooleanReturn a correct value wrapped in a hostile encoding (untrimmed whitespace, invisible/zero-width characters, BOM, or bidi/combining marks). Homoglyphs are excluded so the value stays machine-parseable; it still validates after normalisation.
invalidbooleanReturn a code with a deliberately wrong check character; encoded facts stay valid.
namestringThe given name to encode. When omitted, a plausible random name is generated.
olderThanintegerMinimum age in years at request time.
seedintegerInteger seed for reproducible output: the same seed always yields the same record.
sex"m" | "f"Encoded sex: "m" or "f".
surnamestringThe surname to encode. When omitted, a plausible random surname is generated.
youngerThanintegerMaximum age in years at request time.

Response fields

FieldTypeDescription
valuestringThe full 16-character Codice Fiscale.
surnameCodestringThe 3-letter surname code.
nameCodestringThe 3-letter name code.
birthDatestringThe encoded birth date in ISO `YYYY-MM-DD` form.
sex"m" | "f"Encoded sex: `m` or `f` (women carry a day offset of +40).

Other generators for Italy

See all generators for Italy →

The same kind of identifier elsewhere

Try it

Generate a live example below — every response is valid by format and entirely synthetic.