Spanish Social Security Number (NAF) Generator
Generate and format valid Spanish Social Security Number (NAF) for software testing and development.
About Spanish Social Security Number (NAF)
The NAF is the unique 12-digit number assigned to workers registered in the Spanish Social Security system. It is mandatory for employment in Spain.
This tool generates and validates NAF codes, verifying the last 2 check digits applying the standard Modulo 97 algorithm on the first 10 digits.
Anatomy & Structure of Spanish NAF
The Social Security Affiliation Number (NAF) consists of 12 digits issued by TGSS:
| Position | Field | Length | Meaning & Rule | Example |
|---|---|---|---|---|
| 1 & 2 | Province | 2 digits | INE province code of first registration (e.g., 28 Madrid, 08 Barcelona) | 28 |
| 3 to 10 | Sequential | 8 digits | Unique correlative worker sequential number in Social Security | 12345678 |
| 11 & 12 | Check Digits | 2 digits | Two-digit control checksum calculated using Modulo 97 | 42 |
NAF Validation Algorithm (Modulo 97)
Social Security calculates the control digits using Modulo 97 over the 10-digit base:
- 1. Isolate the first 10 digits (2 province + 8 sequential).
- 2. Parse the sequence as a 10-digit integer.
- 3. Compute the integer remainder modulo 97.
- 4. Format the result as a 2-digit zero-padded string.
- 5. Compare with the 11th and 12th digits of the NAF.
Frequently Asked Questions & Technical Guidelines
How is the NAF check digit calculated?
The first 10 digits are divided by 97. The remainder of this division must exactly match the last 2 digits of the NAF.
Are the data in this tool real or official?
All identifiers generated by this tool are strictly synthetic and calculated via mathematical algorithms for software development and QA testing purposes. Using fake data in official or legal filings is strictly prohibited by law.