Skip to main content
Skip to main content

Spanish Social Security Number (NAF) Validator

Validate the authenticity, format, and checksum of Spanish Social Security Number (NAF).

About Spanish Social Security Number (NAF) Validation

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:

PositionFieldLengthMeaning & RuleExample
1 & 2Province2 digitsINE province code of first registration (e.g., 28 Madrid, 08 Barcelona)28
3 to 10Sequential8 digitsUnique correlative worker sequential number in Social Security12345678
11 & 12Check Digits2 digitsTwo-digit control checksum calculated using Modulo 9742

NAF Validation Algorithm (Modulo 97)

Social Security calculates the control digits using Modulo 97 over the 10-digit base:

DV = (parseInt(Province + Sequential) % 97).padStart(2, "0")
  1. 1. Isolate the first 10 digits (2 province + 8 sequential).
  2. 2. Parse the sequence as a 10-digit integer.
  3. 3. Compute the integer remainder modulo 97.
  4. 4. Format the result as a 2-digit zero-padded string.
  5. 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.