Under the hood

How the Codice Fiscale Is Built

A character-by-character breakdown

Most people see their codice fiscale as a meaningless string of 16 letters and numbers. It isn't. Every character is calculated from something specific about you — your name, your birthday, your gender, where you were born. Once you know the rules, you can read a codice fiscale the way you'd read a passport.

This page walks through exactly how the code is constructed. It's the same calculation our generator runs, laid out by hand so you can see what's happening under the hood.

The short version

A personal codice fiscale is 16 characters, in five parts:

  • 3 letters from your surname
  • 3 letters from your first name
  • 2 digits for your year of birth
  • 1 letter for your month of birth
  • 2 digits for your day of birth (and, hidden inside them, your gender)
  • 4 characters for your place of birth
  • 1 final letter that checks the whole thing for errors

That's 3 + 3 + 5 + 4 + 1 = 16. Here's how each part is worked out.

Part 1: Your surname (3 letters)

Take the consonants of your surname, in order, and use the first three.

  • Rossi → R, S, S → RSS
  • Moretti → M, R, T → MRT

If your surname doesn't have three consonants, vowels fill the gaps, in the order they appear:

  • Masi → M, S + first available vowel A → MSA

And if the whole surname is shorter than three letters, an X is added to fill the space:

  • Fo → F, O + X → FOX

One quirk worth knowing: the algorithm uses the surname on your primary ID document. In Italy, women don't legally change their surname when they marry, so an Italian woman keeps the same code for life. But a foreign woman who gets her codice fiscale after marrying — using a passport that shows her married name — will have a code built from that married surname. Same person, different code depending on which name was on the document at the time.

Part 2: Your first name (3 letters)

Same idea as the surname, with one extra rule. If your first name has four or more consonants, you skip the second one and take the 1st, 3rd, and 4th:

  • Marco → only three consonants (M, R, C) → MRC
  • Riccardo → four+ consonants, skip the 2nd → R, C, R → RCR

If there aren't enough consonants, vowels fill in, exactly like the surname:

  • Paola → P, L + A → PLA

If you have more than one first name, they're treated as a single run of letters with no space between them.

Part 3: Your year and month of birth (3 characters)

The year is just the last two digits — someone born in 1991 gets 91.

(This is also why the code can occasionally collide between people: it doesn't store the century. Someone born in 1907 and someone born in 2007 both encode as "07.")

The month is a single letter, but the mapping isn't A, B, C straight down the calendar. It skips around:

MonthLetterMonthLetter
JanuaryAJulyL
FebruaryBAugustM
MarchCSeptemberP
AprilDOctoberR
MayENovemberS
JuneHDecemberT

So April is D, August is M, December is T.

Part 4: Your day of birth — and your gender (2 digits)

This is the clever part. The two digits encode your birth day and your gender at the same time.

  • Men: the day as-is, 01 through 31.
  • Women: the day plus 40, so 41 through 71.

A man born on the 8th gets 08. A woman born on the 8th gets 48. That's how a 16-character code carries gender without spending a separate character on it — anything over 40 in this position means female.

Part 5: Your place of birth (4 characters)

This is the codice catastale (also called the Belfiore code): one letter followed by three digits.

Every Italian comune has its own code, assigned roughly in alphabetical order — Abano Terme, first alphabetically, is A001. Milan is F205.

If you were born outside Italy, your code starts with Z followed by a three-digit country code. A few common ones:

  • United States → Z404
  • United Kingdom → Z114
  • Australia → Z700

This is the single biggest reason foreign-born people sometimes end up sharing a code (more on that below): everyone born in the same country gets the same four characters here, so there's far less variation than there is among Italian towns.

Part 6: The check character (1 letter)

The last letter isn't personal data — it's a checksum. It's calculated from the previous 15 characters using a fixed procedure: the characters in odd positions and even positions are each converted to numbers using two different tables, the totals are added, divided by 26, and the remainder maps to a final letter.

You'll never need to do this by hand. Its only job is to catch typos — if someone mistypes a character, the check letter almost certainly won't match, and the code gets flagged as invalid. It's the same principle behind the last digit of a credit card number.

Putting it together: a worked example

Take a fictional Matteo Moretti, male, born in Milan on 8 April 1991:

  • Surname Moretti → MRT
  • Name Matteo → MTT
  • Year 1991 → 91, April → D, day 08 (male) → 08
  • Born in Milan → F205
  • Check character → J

MRTMTT91D08F205J

And a fictional Samantha Miller, female, born in the USA on 25 September 1982:

  • Surname Miller → MLL
  • Name Samantha → SNT
  • Year 1982 → 82, September → P, day 25 + 40 (female) → 65
  • Born in the USA → Z404
  • Check character → U

MLLSNT82P65Z404U

What about companies?

Everything above is for natural persons — actual people. A codice fiscale for a company or other legal entity works completely differently. It's 11 digits, not 16 characters, and it isn't calculated from a name at all. It's simply a sequential number assigned by the tax authority, with no hidden meaning. There's no formula to reverse-engineer — which is why a generator like this one only produces codes for individuals.

When the formula produces a collision: omocodia

Because the algorithm throws away information — vowels, the century, the exact birthplace for foreigners — two different people can occasionally compute to the exact same code. This is called omocodia, and it's most common among people born abroad, since they share those broad country codes.

When the Agenzia delle Entrate detects a collision during official registration, it resolves it by swapping certain digits in the code for letters, using a substitution table set by law, and then recalculating the check character. You don't do anything — the tax office handles it automatically when they register you. Our generator produces the standard computed code; if you're one of the rare omocodia cases, you'll find out only when your official code is issued.

Calculate yours

Now that you know what each piece means, you can generate your own codice fiscale and read it back character by character. The code you get is mathematically identical to the one the Agenzia delle Entrate would issue — it just hasn't been registered yet. If you need it officially registered, that's a separate step a licensed representative can handle remotely.

This explanation is for informational purposes. The only official codice fiscale is the one issued and registered by the Agenzia delle Entrate. CodiceFiscale.ai is not affiliated with the Italian government.