---
id: "es_dni"
kind: "datatype"
status: "draft"
is_pii: true
categories: ["pii", "persons"]
country: ["ES"]
langs: ["es"]
quality: 100
url: "http://registry.apicrafter.io/datatype/es_dni"
---

# Spanish national identity document number (DNI) (`es_dni`)

> **Draft.** Draft records have not been reviewed yet and may be incomplete or wrong; do not treat them as authoritative for legal or compliance decisions.

Documento Nacional de Identidad, the identity number of Spanish citizens: eight digits and a check letter, which is the number modulo 23 looked up in TRWAGMYFPDXBNJZSQVHLCKE. The same value is the person's tax number (NIF). Foreigners receive an NIE instead.

- Parent datatype: `esnif`
- Personal data (PII): yes
- Categories: Personally identifiable information (pii), Person related (persons)
- Countries: Spain (ES)
- Languages: Spanish (es)
- Classification: identifier

## Detection

Regular expression (Python `re`):

```
^\d{8}-?[A-Z]$
```

Check digit algorithm: `es_dni`

## Examples

- `12442144H` — Synthetic number with a valid check digit
- `85103532J` — Synthetic number with a valid check digit
- `54362315-K` — python-stdnum test value, with a hyphen before the letter
- `12442144A` (invalid example) — Check letter does not match
- `12442144H7` (invalid example) — One character too many

## Mappings

- dpv: `pd:OfficialID`
- google_dlp: `SPAIN_DNI_NUMBER`
- purview: `Spain DNI`, `EU national identification number`
- stdnum: `es.dni`

## Supported by tools

- `amazonmacie`
- `awsglue`
- `azureailanguage`
- `databricks`
- `dataprep`
- `googledlp`
- `ibmguardium`
- `microsoftpurview`
- `nightfall`
- `pythonstdnum`
- `snowflake`

## Translations

- es: Documento Nacional de Identidad (DNI)

## Sources

- wikipedia: <https://en.wikipedia.org/wiki/Documento_Nacional_de_Identidad_(Spain)>
- wikipedia: <https://es.wikipedia.org/wiki/Documento_nacional_de_identidad_(Espa%C3%B1a)>
- other: <https://arthurdejong.org/python-stdnum/doc/2.2/stdnum.es.dni.html>
- other: <https://docs.dataprep.ai/user_guide/clean/clean_es_dni.html>

## Quality

Score 100/100.

JSON: <http://registry.apicrafter.io/api/v1/datatypes/es_dni.json> · Edit: <https://github.com/apicrafter/metacrafter-registry/edit/main/data/datatypes/ES/persons/es_dni.yaml>
