NIE by e-residence

NIE number format: anatomy of the 9-character code

TL;DR

  • A Spanish NIE is 9 characters: a leading letter (X, Y, or Z), seven digits, and a final check letter — for example X1234567B.
  • The leading letter is a series marker: X (until 2008) · Y (2008) · Z (2022, current). All three equally valid forever.
  • The check letter is mod 23 of the digit-only form. Replace X→0 / Y→1 / Z→2, divide by 23, take the remainder, match against TRWAGMYFPDXBNJZSQVHLCKE.
  • Officially no hyphens, no spaces. Hyphenated versions on old paperwork are the same number.
  • The NIE is assigned once, for life, and is never reassigned.

NIE service since 2013 · 17 000+ clients handled · 4.9★ on Trustpilot

Facts verified 22 September 2026 against the Sede Electrónica de la Policía Nacional and Orden INT/2058/2008.


Key facts: NIE format

StructureLetter (X/Y/Z) + 7 digits + check letter
ExampleX1234567B
Length9 characters, always
First letterX (until 2008), Y (2008–2022), Z (since 2022)
Official spellingNo hyphens, no spaces
Check letter algorithmmod 23 of the digit-only form (X→0, Y→1, Z→2)
Letter tableT R W A G M Y F P D X B N J Z S Q V H L C K E
CaseUppercase only — no lowercase, no lowercase variants
The number changes?Never — assigned once, for life
Online generatorsProduce strings that pass checksum but exist in no database — not real

Three blocks: series letter · 7 digits · check letter. Total 9 characters.

What the first letter means

The first letter is simply a series marker — it tells you roughly when the number was issued, nothing else:

  • X — the original series, used until 2008 and now exhausted.
  • Y — introduced in July 2008 by Orden INT/2058/2008 when the X series ran out.
  • Z — the current series, issued since 2022.

An X-number is not "older and less valid" than a Z-number. All three series are equally valid forever. If your certificate is from 2005 and starts with X, that is still your number today.


How the check letter is calculated

The last letter is a checksum, and you can verify it yourself. Spain uses the same algorithm as for DNI numbers:

  1. Replace the first letter with a digit: X → 0, Y → 1, Z → 2.
  2. You now have an 8-digit number. Divide it by 23 and take the remainder.
  3. Match the remainder (0–22) against the letter table: T R W A G M Y F P D X B N J Z S Q V H L C K E.

Worked example. Y 2 3 4 5 6 7 8 → 12345678 → 12345678 mod 23 = 14 → the 15th letter (index 14) is Z → full NIE: Y1234567Z.

Banks and notaries run exactly this validation — a typo in one digit makes the whole number invalid and triggers a "wrong NIE" rejection at the bank counter.


Where to find your NIE on documents

  • White A4 NIE certificate — the number is in the centre, under your name.
  • Green EU registration certificate (CUE) — top right, labelled NIE.
  • TIE card — top right corner of the card.
  • Visa sticker in a passport — some long-stay visas print the NIE assigned during the application; look for a 9-character X/Y/Z code on the visa vignette.

What the NIE format is NOT

  • ✗ Not a DNI. Spanish citizens' DNI has 8 digits + letter, with no leading X/Y/Z. If there is no X, Y or Z at the front, it is not a NIE.
  • ✗ Not a NUSS. The social security number is 12 digits and completely unrelated.
  • ✗ Not a CIF. Company tax IDs start with other letters (A, B, …) — that's a business identifier, not a personal one.
  • ✗ Not case-sensitive trickery. There are no lowercase NIEs and no NIEs with more or fewer than seven digits. Anything else is a typo or a fake.
  • ✗ Not something an online "NIE generator" can issue. Generators produce strings that pass the checksum but exist in no police database — only the Dirección General de la Policía assigns real NIEs.

Frequently asked questions

What format is a Spanish NIE number?

Nine characters: a leading letter X, Y or Z, seven digits, and a final check letter. Example: X1234567B. Officially it is written without hyphens or spaces, although you will see formats like X-1234567-B on older documents.

What does the first letter of a NIE mean?

Series marker — roughly when it was issued. X = until 2008, Y = 2008, Z = 2022 (current). All three are equally valid forever.

How is the NIE check letter calculated?

Spain uses the same mod-23 algorithm as for DNI numbers. Replace X→0, Y→1, Z→2 to get an 8-digit number, compute modulo 23, and match against TRWAGMYFPDXBNJZSQVHLCKE.

Can two people have the same NIE?

No. The number is unique and permanent — assigned once, for life, never reassigned. If you change address, employer, or visa type, you keep the same NIE.

Where do I find my NIE on documents?

White A4 NIE certificate (centre, under your name). Green EU certificate (top right). TIE card (top right corner). Some visa stickers carry the NIE assigned during the application.

Is a NIE the same as a DNI?

No. DNI is for Spanish citizens (8 digits + letter, no X/Y/Z). NIE is for foreigners (9 characters, leading X/Y/Z). The leading letter is the visual marker.

Can an online NIE generator give me a real NIE?

No. Generators produce strings that pass the mod-23 checksum but exist in no police database. Only the Dirección General de la Policía assigns real NIEs, and only on application.




Sources

  • Sede Electrónica de la Policía Nacional — Asignación de NIE (NIE assignment, format)
  • Orden INT/2058/2008, de 5 de julio — introduction of the Y series (BOE-A-2008-12050)
  • Real Decreto 557/2011 — Reglamento de Extranjería (assignment procedure)

Reviewed by the Happy Residence S.L. team. Format and algorithm verified against the same source Spain uses for DNI validation. We re-verify after each fee order. We are an administrative assistance service, not a public administration.

We Are Online