NIE Generator

Generator

Generate valid Spanish NIE numbers for testing. Implements the official Mod 23 check letter algorithm used for foreign nationals residing in Spain. For testing purposes only.

Generator Options
Generated NIE
Click "Generate NIE" to create a test number
Sponsored

Travel insurance built for nomads

Comprehensive medical and travel coverage wherever you go. No long-term commitment required.

Coverage in 185+ countries
Cancel or pause anytime
Home country coverage included

Looking for the Portuguese NIF instead?

This tool generates the Spanish NIE (foreigner ID). If you need the Portuguese tax number, use our NIF Generator →

About this tool

About NIE Generator

The Spanish NIE (Número de Identificación de Extranjero) is the identification number issued to foreign nationals who reside in, work in, or have tax obligations in Spain — required for buying property, opening a bank account, signing an employment contract, or forming a company. It consists of a prefix letter (X, Y, or Z) followed by 7 digits and a check letter, computed with the same Mod 23 algorithm used for the Spanish DNI. This generator produces format-valid NIE numbers for testing purposes only — they pass the check letter algorithm but are not assigned to any real person.

Every generated NIE follows the official Mod 23 algorithm: the prefix letter is mapped to a digit (X=0, Y=1, Z=2), prepended to the 7-digit body, and the resulting 8-digit number is taken modulo 23 to select the check letter from the table 'TRWAGMYFPDXBNJZSQVHLCKE' — the identical table and method used for DNI. You can pick a specific series (X, Y, or Z) or let the generator choose one at random.

Ideal for testing Spain-facing applications: property purchase and rental platforms, banking KYC onboarding, HR and payroll systems, immigration and relocation software, and any form that collects a NIE from foreign residents. Use it to populate staging environments and test suites without using a real person's identification number.

Generated NIEs pass the official Mod 23 check letter validation used by Spanish systems. The numbers are entirely fictitious — no real person is associated with them. All generation happens in the browser with no network requests.

Key Features

  • Official Mod 23 check letter algorithm, reused from the DNI generator
  • Choose the X, Y, or Z series, or generate at random
  • X/Y/Z prefix + 7-digit body + check letter format
  • Passes all format-level NIE validators, including this site's own
  • 100% browser-based, no data sent
  • For testing purposes only

FAQ

NIE Generator — Frequently Asked Questions

Can I use a generated NIE for official purposes?

No. Generated NIEs pass the Mod 23 check letter algorithm but are not assigned to any real person by the Spanish Dirección General de la Policía. They cannot be used to open a bank account, sign a contract, buy property, or for any official transaction. These numbers are strictly for software testing and development.

What is the difference between a NIE and a DNI?

DNI (Documento Nacional de Identidad) is issued to Spanish citizens. NIE (Número de Identificación de Extranjero) is issued to foreign nationals who reside in, work in, or have tax obligations in Spain. Both use the same 8-digit Mod 23 check letter algorithm — for NIE, the X/Y/Z prefix is first converted to 0/1/2 before the modulus is computed.

What do the X, Y, and Z series mean?

The prefix indicates when the NIE was issued: X was used before July 2008, Y from July 2008 onward, and Z is a newer series introduced once the Y range approached exhaustion. The series does not change how the check letter is calculated — it's simply mapped to 0, 1, or 2 respectively before the Mod 23 operation.

Is a NIE the same as a TIE card?

No. The NIE is just the identification number. The TIE (Tarjeta de Identidad de Extranjero) is the physical card that displays it, issued to foreign residents who hold a residence permit. Non-resident foreigners can be assigned a NIE — for a property purchase or a one-off transaction, for example — without ever holding a TIE card.

Tips

  • Use the NIE Validator page to verify a generated or real-world NIE number
  • The same Mod 23 table used for DNI applies to NIE — just map X→0, Y→1, Z→2 first
  • Never test with a real NIE; use generated ones to protect privacy
  • A NIE alone is not proof of Spanish residency — that requires the TIE card or an EU registration certificate

Explore more

Related Tools

Other tools that might be useful for your workflow