Generator · French data
French NIR
Endpoint GET /v1/fr/nir
What it covers
Returns a valid French NIR (numéro de sécurité sociale) with a correct control key. Constrain with `sex` and age/birth-date filters (year and month are encoded; the day is not). Contradictory combinations are rejected with a 400. Set `invalid=true` for a deliberately wrong key.
How it’s calculated
The French NIR (numéro de sécurité sociale) ends in a two-digit control key equal to 97 minus the 13-digit significant part taken modulo 97.
Algorithm
- Build the 13-digit significant part by concatenating, with zero-padding, these fields in order: S = sex digit (1 for male, 2 for female); YY = birth year modulo 100, two digits; MM = birth month, two digits; DD = department code, two digits (this generator draws 01-95); CCC = commune code, three digits (drawn 001-990); OOO = order number, three digits (drawn 001-999).
- Concatenation yields exactly 13 digits: S YY MM DD CCC OOO. Treat this whole 13-digit string as a single base-10 integer N (use big-integer arithmetic; 13 digits exceeds 32-bit range).
- Compute R = N mod 97.
- Compute the control key K = 97 - R.
- Format K as a two-digit string, left-padded with a zero if K < 10 (K ranges 1..97, so it is always 1 or 2 digits).
- Append the two-digit K to the 13-digit significant part. The full NIR is 15 characters: 13 significant digits followed by the 2-digit key.
Worked example
Male born April 1980, department 75, commune 108, order 042 -> 1800475108042 + key ?
Sex digit S = 1 (male).
YY = 1980 mod 100 = 80.
MM = 04 (April).
Department DD = 75.
Commune CCC = 108.
Order OOO = 042.
Significant part N = 1 80 04 75 108 042 = 1800475108042 (13 digits).
R = 1800475108042 mod 97 = 95.
K = 97 - 95 = 2.
Zero-pad K to two digits: 02.
Full NIR = 1800475108042 concatenated with 02 = 180047510804202.The control key is 02, giving the full NIR 180047510804202.
Edge cases
- The first digit encodes sex: 1 = male, 2 = female (this generator only emits 1 or 2; the real NIR also uses 3-4 and 7-8 for certain non-mainland/foreign registrations, which this generator does not produce).
- The control key K = 97 - (N mod 97) ranges from 1 to 97 and is always emitted as two digits (e.g. a residue of 0 would give K = 97, a residue of 96 gives K = 01).
Gotchas
- The modulus is applied to the entire 13-digit significant part as one integer, not to a weighted digit sum — use BigInt / big-integer math because 13 digits overflows 32-bit and even standard 53-bit float precision for the mod operation is unsafe; the primitive uses BigInt(numericString) % 97n.
- This generator uses purely numeric department codes (01-95) and does NOT emit the Corsica codes 2A/2B, so it never needs the real-world rule of substituting 2A->19 and 2B->18 before the mod-97 computation.
- The birth day is not encoded in the NIR at all — only sex, year-mod-100, and month are taken from the birth date; the day drawn is discarded.
Parameters
| Parameter | Type | Description |
|---|---|---|
| atAge | integer | Exact age in years at request time. |
| bornAfter | stringpattern ^\d{4}(?:-\d{2}(?:-\d{2})?)?$ | Born after this date or fragment (YYYY, YYYY-MM, YYYY-MM-DD). |
| bornBefore | stringpattern ^\d{4}(?:-\d{2}(?:-\d{2})?)?$ | Born before this date or fragment (YYYY, YYYY-MM, YYYY-MM-DD). |
| bornOn | stringpattern ^\d{4}(?:-\d{2}(?:-\d{2})?)?$ | Born on a date or within a fragment: YYYY, YYYY-MM, or YYYY-MM-DD. |
| count | integer1–1000 | Number of records to return, 1–1000 (your plan may lower this). Omitted returns a single record; set it for a batch. |
| edge | boolean | Restrict output to edge-case values. |
| extreme | boolean | Return a correct value wrapped in a hostile encoding (untrimmed whitespace, invisible/zero-width characters, BOM, or bidi/combining marks). Homoglyphs are excluded so the value stays machine-parseable; it still validates after normalisation. |
| invalid | boolean | Return a NIR with a deliberately wrong control key; sex/year/month stay valid. |
| olderThan | integer | Minimum age in years at request time. |
| seed | integer | Integer seed for reproducible output: the same seed always yields the same record. |
| sex | "m" | "f" | Encoded sex: "m" or "f". |
| youngerThan | integer | Maximum age in years at request time. |
Response fields
| Field | Type | Description |
|---|---|---|
| value | string | The 15-character NIR. |
| digits | string | The canonical 15-character NIR. |
| sex | "m" | "f" | Encoded sex: `m` (1) or `f` (2). |
| birthYear | integer | The full four-digit birth year. |
| birthMonth | integer | The birth month, 1–12. |
Other generators for France
French companyFrench company nameFrench email addressFrench IBANFrench personFrench person nameFrench product or service offeringFrench SIRENFrench vehicle registration plate
See all generators for France →The same kind of identifier elsewhere
Austrian data · Austrian SVNRBelgian data · Belgian RijksregisternummerBulgarian data · Bulgarian EGNCroatian data · Croatian JMBGCroatian data · Croatian OIBCypriot data · Cyprus TICCzech data · Czech rodné čísloDanish data · Danish CPRDutch data · Dutch BSNEstonian data · Estonian isikukoodFinnish data · Finnish henkilötunnusFinnish data · Finnish Y-tunnusGerman data · German Steuer-IdNrGreek data · Greek AFMGreek data · Greek AMKAHungarian data · Hungarian adóazonosító jelHungarian data · Hungarian személyi azonosítóHungarian data · Hungarian TAJIrish data · Irish PPSNItalian data · Italian Codice FiscaleLatvian data · Latvian personas kodsLithuanian data · Lithuanian asmens kodasLuxembourg data · Luxembourg matriculePolish data · Polish PESELPortuguese data · Portuguese NIFRomanian data · Romanian CNPSlovak data · Slovak rodné čísloSlovenian data · Slovenian davčna številkaSlovenian data · Slovenian EMŠOSpanish data · Spanish DNISpanish data · Spanish NIESwedish data · Swedish personnummer
Try it