Launching a SaaS?·Collect waitlist signups before you build — before.run
SandboxPatternsDetectDocsChangelog
Identity
es
#nif
#dni
#nie
#spain

Spanish NIF / DNI

Matches a Spanish National Identity Document number (NIF/DNI) — 8 digits followed by a letter, or an NIE starting with X, Y, or Z.

✓ Spanish government forms✓ Bank KYC✓ Online identity verification
/
/
Safe
Test String
3 matches
[…]Character class […]— Matches any single character listed in this set
0-90-9— 0-9 — range from '0' to '9'
XX— 'X' — literal character
YY— 'Y' — literal character
ZZ— 'Z' — literal character
\d{7}digit— \d — digit (0–9) — repeated exactly 7 times · {7} — exactly 7 times
[…]Character class […]— Matches any single character listed in this set
A-HA-H— A-H — range from 'A' to 'H'
J-NJ-N— J-N — range from 'J' to 'N'
P-TP-T— P-T — range from 'P' to 'T'
V-ZV-Z— V-Z — range from 'V' to 'Z'
Pattern: 27 charsInput: 29 chars
100% client-side · private

✓ Valid Examples

  • 12345678Z
  • X1234567L
  • Y0000000T

✗ Invalid Examples

  • 1234567Z
  • 123456789Z
  • 12345678I

Usage & Integration

Validate Spanish NIF / DNI natively in your backend or frontend without copying regex strings.

Node / Edge

import { validate } from '@regexto/validators';

validate('es-nif', '...');

Python

from regexto_validators import validate

validate("es-nif", "...")

Go

import "github.com/regex-to/validators-go"

valid, err := validators.Validate("es-nif", "...")

PHP

use RegexTo\Validators\Validator;

Validator::validate('es-nif', '...');

Rust

use regexto_validators::validate;

let is_valid = validate("es-nif", "...").unwrap();