How does the Modulo-23 check letter work for Spanish DNI and NIE?
Spanish personal tax numbers verify integrity by dividing an 8-digit integer by 23 and mapping the remainder (0 through 22) to the official 23-letter sequence TRWAGMYFPDXBNJZSQVHLCKE. Any single-digit typo or adjacent digit transposition changes the remainder and fails the check immediately.
Under Spanish Real Decreto 1553/2005 on DNI Control Letter, the Ministry of the Interior applies this exact Modulo-23 lookup table to national identity cards and resident foreigner numbers alike.
Personal DNI numbers and X, Y, Z foreigner NIE prefixes
A standard DNI consists of 8 digits followed by one control letter, rejecting 00000000 as an invalid placeholder. For a foreigner NIE starting with X, Y, or Z followed by 7 digits, the validator substitutes 0 for X, 1 for Y, and 2 for Z to form an 8-digit integer before computing % 23.
When onboarding Central European vendors alongside Spanish contractors, you can also validate 10-digit Polish NIP tax numbers offline using the same local browser workflow.
Special personal NIF prefixes K, L, and M
The Spanish tax agency assigns K to minors under 14, L to Spaniards residing abroad without a DNI, and M to foreign nationals without an NIE. Each carries 7 serial digits and a trailing letter verified by Modulo-23 over those 7 digits, rejecting 0000000 bodies.
Adding a leading ES prefix converts any normalized 9-character NIF, NIE, or CIF into an 11-character EU VAT identifier suitable for cross-border Spanish invoices.
Corporate CIF control character rules and entity prefixes
Legal entities and unincorporated associations carry a 9-character identifier beginning with an entity-type letter (A through W), 2 provincial digits, 5 registration digits, and a final control character. The validator sums the digits at even positions (2, 4, 6) and adds the digit-sum of twice each digit at odd positions (1, 3, 5, 7), subtracting the units digit from 10 modulo 10.
According to Spanish Orden EHA/451/2008 on Entity NIF Structure, the initial entity prefix and provincial code determine whether that final character must be numeric (0 to 9) or alphabetic (JABCDEFGHI).
| Entity prefix group | Representative legal forms | Allowed control character | Example normalized format |
|---|---|---|---|
| A, B, E, H | S.A., S.L., comunidades de bienes, homeowner boards | Numeric digit (0 to 9) only |
B-1234567-4 |
| N, P, Q, R, S, W | Foreign entities, municipalities, public bodies, religious orders | Alphabetic letter (J to I) only |
Q-2818002-D |
| 00 provincial code | Non-resident legal entities regardless of prefix | Alphabetic letter (J to I) only |
A-0012345-E |
| C, D, F, G, J, U, V | Cooperatives, associations, civil partnerships, joint ventures | Either numeric digit or letter | G-1234567-4 |
| DNI / NIE / K, L, M | Natural persons, sole traders (autónomos), non-residents |
Modulo-23 letter (TRWAGMYFPDXBNJZSQVHLCKE) |
12345678-Z |
If your finance team also processes Mediterranean vendor records, switch to the Italian Partita IVA checker to verify 11-digit Luhn checksums and provincial office codes.
Batch checking up to 1,000 Spanish tax IDs and Facturae prep
Pasting vendor master lists directly into Spanish NIF, NIE or CIF number or list lets accounts payable teams audit up to 1,000 numbers at once within the 50,000-character input limit. Results update immediately into a filterable table showing normalized strings, formatted hyphens, and pass or fail diagnostics.
Stripping ES prefixes and exporting clean CSV or Excel audits
The normalizer strips leading ES country codes, spaces, dots, and hyphens before running checksum math. In batch mode, toggle All, Passed, or Failed to isolate broken vendor records, then click Download results (CSV) or Download Excel (.xlsx) for spreadsheet sign-off.
Exported CSV files include a UTF-8 byte-order mark and defensive formula escaping, while Excel .xlsx workbooks are built in a local Web Worker at 0 KB network cost.
Pre-validating supplier IDs before Facturae XML billing
Under the EU VAT Directive 2006/112/EC, intra-community invoices require valid ES-prefixed VAT numbers for both issuer and buyer. Before submitting electronic invoices to Spanish public administrations, you can inspect Spanish Facturae e-invoice XML files in your browser to confirm matching tax IDs.
Offline checksum limits vs live AEAT census verification
Local Modulo-23 and CIF arithmetic executes with 0 bytes leaving your browser, making it safe for confidential payroll, customer onboarding, and supplier audits. However, a passing mathematical check digit proves structural validity only and cannot replace official registry queries.
What local validation catches without network exposure
Offline verification immediately detects missing characters, swapped adjacent digits, zeroed placeholder strings, and mismatched entity-prefix control types. Catching these formatting errors locally prevents rejected Facturae submissions and failed SEPA supplier onboarding imports.
Tip: Click Copy compact on single-number checks when pasting into ERP or EU VIES forms that reject hyphens, or Copy formatted for human-readable contracts and PDF invoices.
Informational scope and European supplier verification
This validator is provided for informational and operational convenience only and does not constitute tax or legal advice. Always verify active census status, VAT registration, and legal entity standing directly with the Agencia Tributaria (AEAT) or a qualified accountant, and retain supporting tax records for at least 4 years under Spanish tax audit rules.
For cross-border supplier audits extending into neighboring jurisdictions, you can also catch French supplier SIRET typos before European payouts using the same client-side batch workflow.