Regular Expressions for French Forms

Here is a list of the most useful and specific JavaScript regular expressions (regex) for the French format. These regexes cover the most frequent use cases for validating forms in France:

How to use them in JavaScript?

To test if a string matches your regex, the most common method is test(), which returns a boolean (true or false).

const regexTelephone = /^(?:(?:\+|00)33|0)\s*[1-9](?:[\s.-]*\d{2}){4}$/;

const numero = "06 12 34 56 78";

const estValide = regexTelephone.test(numero); // Returns true

1. French phone number

Accepts local formats (01, 06, 07, etc.) as well as international formats (+33 or 0033), with or without spaces, dashes, or dots.

const regexTelephone = /^(?:(?:\+|00)33|0)\s*[1-9](?:[\s.-]*\d{2}){4}$/;

2. French zip code

Validates 5-digit zip codes. This simple regex accepts all departments, from 01000 to 98999.

const regexCodePostal = /^[0-9]{5}$/;

3. Social Security Number (NIR)

Validates the 15-digit social security number format (13 digits + 2 key digits), including the handling of Corsican departments (2A and 2B).

const regexSecu = /^[12]\d{2}(0[1-9]|1[0-2]|2[0]|3[0])(2[AB]|\d{2})\d{3}\d{3}\d{2}$/;

4. License plate (Current SIV format)

Validates the format of current French license plates (type AB-123-CD), with or without dashes.

const regexPlaque = /^[A-Z]{2}[- ]?\d{3}[- ]?[A-Z]{2}$/i;

5. SIREN Number (Companies)

The SIREN is a unique 9-digit identifier assigned to each French company.

const regexSiren = /^\d{9}$/;

6. SIRET Number (Establishments)

The SIRET consists of the 9 digits of the SIREN followed by the 5 digits of the NIC (Numéro Interne de Classement).

const regexSiret = /^\d{14}$/;

7. French Intracommunity VAT Number

Starts with “FR” followed by 2 characters (digits or letters) and the 9 digits of the SIREN.

const regexTVA = /^FR[A-Z0-9]{2}[ ]?\d{9}$/i;

French IBAN

The French IBAN is exactly 27 characters long. It starts with “FR”, followed by 2 digits (control key), then the full RIB (bank, branch, account, key).

const regexIbanFR = /^FR\d{2}[ ]?[A-Z0-9]{4}[ ]?[A-Z0-9]{4}[ ]?[A-Z0-9]{4}[ ]?[A-Z0-9]{4}[ ]?[A-Z0-9]{4}[ ]?[A-Z0-9]{3}$/i;