ibanchecker.cash
Developer ResourcesJune 3, 2026 · 7 min read

How to Convert a French RIB to IBAN — Step by Step

Convert a French RIB (code banque, code guichet, account number) to a valid FR IBAN. Covers the Clé RIB formula, MOD-97 check digits, Python and TypeScript code, and common mistakes.

Share

Converting a French RIB to IBAN requires two separate calculations: first the Clé RIB (a domestic check digit), then the IBAN check digits via MOD-97. This guide covers both algorithms with working code examples and explains when each format is used in French banking.

What Is a French RIB?

A RIB (Relevé d'Identité Bancaire) is France's legacy bank account identifier. Every French account has one, and it is still printed on chequebooks and displayed in online banking portals. A RIB contains four fields:

  • Code Banque — 5 digits identifying the bank (e.g. 30004 = BNP Paribas)
  • Code Guichet — 5 digits identifying the branch
  • Numéro de Compte — 11 characters (digits and/or uppercase letters)
  • Clé RIB — 2-digit domestic check key

When SEPA was fully implemented in February 2014, French banks began requiring IBANs for all credit transfers and direct debits. The RIB is now used mainly as a reference document — the payment system runs on the derived IBAN.

The French IBAN Structure

A French IBAN is always 27 characters:

FR kk BBBBB GGGGG AAAAAAAAAAA KK

FR            country code
kk            2 IBAN check digits (MOD-97, positions 3–4)
BBBBB         code banque (5 digits)
GGGGG         code guichet (5 digits)
AAAAAAAAAAA   numéro de compte (11 chars)
KK            Clé RIB (2 digits)

The BBAN (Basic Bank Account Number) is 23 characters: bank + branch + account + RIB key. The IBAN wraps the BBAN with the country code and two check digits.

Step 1: Calculate the Clé RIB

The Clé RIB uses a French-specific letter-to-digit conversion table and a weighted modulo formula. Letters in the account number are first converted to single digits:

A, J  →  1
B, K, S  →  2
C, L, T  →  3
D, M, U  →  4
E, N, V  →  5
F, O, W  →  6
G, P, X  →  7
H, Q, Y  →  8
I, R, Z  →  9

Then the weighted sum is computed and the check key derived:

Clé RIB = 97 − ((89 × bank_numeric + 15 × branch_numeric + 3 × account_numeric) mod 97)

Where "numeric" means each character has been converted through the table above (digits remain as-is). Because bank and branch codes are pure digits, they do not need conversion. Only the account number may contain letters.

Step 2: Compute the IBAN Check Digits

Once you have the Clé RIB, append it to the BBAN to form the 23-character BBAN. Then apply the standard ISO 13616 MOD-97 algorithm:

  1. Rearrange: move the country code and "00" to the end of the BBAN → BBAN + "FR00"
  2. Convert letters to digits: A=10, B=11, ..., Z=35
  3. Compute the numeric string mod 97
  4. IBAN check digits = 98 − remainder, zero-padded to 2 digits
String to evaluate: BBAN + "FR00"
After conversion:   all-digit string
Check digits:       98 − (string mod 97)

Complete Python Implementation

LETTER_MAP = {
    'A': 1, 'J': 1,
    'B': 2, 'K': 2, 'S': 2,
    'C': 3, 'L': 3, 'T': 3,
    'D': 4, 'M': 4, 'U': 4,
    'E': 5, 'N': 5, 'V': 5,
    'F': 6, 'O': 6, 'W': 6,
    'G': 7, 'P': 7, 'X': 7,
    'H': 8, 'Q': 8, 'Y': 8,
    'I': 9, 'R': 9, 'Z': 9,
}

def rib_mod97(s: str) -> int:
    r = 0
    for ch in s.upper():
        d = LETTER_MAP.get(ch, int(ch))
        r = (r * 10 + d) % 97
    return r

def cle_rib(bank: str, branch: str, account: str) -> str:
    key = 97 - ((89 * rib_mod97(bank) + 15 * rib_mod97(branch) + 3 * rib_mod97(account)) % 97)
    return str(key).zfill(2)

def iban_check_digits(country: str, bban: str) -> str:
    s = bban + country + "00"
    numeric = "".join(
        str(ord(ch) - 55) if ch.isalpha() else ch
        for ch in s.upper()
    )
    remainder = int(numeric) % 97
    return str(98 - remainder).zfill(2)

def rib_to_iban(bank: str, branch: str, account: str) -> str:
    rib_key = cle_rib(bank, branch, account)
    bban = bank + branch + account.upper() + rib_key
    check = iban_check_digits("FR", bban)
    return "FR" + check + bban

# Example
iban = rib_to_iban("30004", "00001", "0500013M026")
print(iban)  # FR76 3000 4000 0105 0001 3M02 6

# Format with spaces
formatted = " ".join(iban[i:i+4] for i in range(0, len(iban), 4))
print(formatted)

JavaScript / TypeScript Implementation

const LETTER_MAP: Record<string, number> = {
  A: 1, J: 1, B: 2, K: 2, S: 2, C: 3, L: 3, T: 3,
  D: 4, M: 4, U: 4, E: 5, N: 5, V: 5, F: 6, O: 6, W: 6,
  G: 7, P: 7, X: 7, H: 8, Q: 8, Y: 8, I: 9, R: 9, Z: 9,
};

function ribMod97(s: string): number {
  let r = 0;
  for (const ch of s.toUpperCase()) {
    const d = LETTER_MAP[ch] ?? parseInt(ch, 10);
    r = (r * 10 + d) % 97;
  }
  return r;
}

function cleRIB(bank: string, branch: string, account: string): string {
  const key = 97 - ((89 * ribMod97(bank) + 15 * ribMod97(branch) + 3 * ribMod97(account)) % 97);
  return String(key).padStart(2, "0");
}

function ibanCheckDigits(country: string, bban: string): string {
  const s = (bban + country + "00").toUpperCase();
  const numeric = s.split("").map(ch =>
    ch >= "A" && ch <= "Z" ? String(ch.charCodeAt(0) - 55) : ch
  ).join("");
  let r = 0;
  for (const ch of numeric) r = (r * 10 + parseInt(ch)) % 97;
  return String(98 - r).padStart(2, "0");
}

function ribToIBAN(bank: string, branch: string, account: string): string {
  const ribKey = cleRIB(bank, branch, account);
  const bban = bank + branch + account.toUpperCase() + ribKey;
  return "FR" + ibanCheckDigits("FR", bban) + bban;
}

Validating the Result

After generating the FR IBAN, validate it to confirm the check digits are correct and that the BBAN length is exactly 23 characters (making the full IBAN 27 characters). You can use the ibanchecker.cash API for programmatic validation or the IBAN checker for a manual check.

curl -X POST https://ibanchecker.cash/api/v1/validate \
  -H "Content-Type: application/json" \
  -d '{"iban": "FR7630004000010500013M026"}'

# Response
{
  "valid": true,
  "iban": "FR76 3000 4000 0105 0001 3M02 6",
  "country": "France",
  "length": 27
}

Common Mistakes

  • Wrong letter conversion table: The RIB uses A,J→1; B,K,S→2; etc. This is NOT the same as the IBAN check digit table (A=10, B=11…). Using the wrong table gives an incorrect Clé RIB.
  • Applying MOD-97 twice: The Clé RIB is a separate calculation from the IBAN check digits. They use different algorithms and different input strings.
  • Account number length: The numéro de compte is always 11 characters. Shorter account numbers must be padded with leading zeros.
  • Lowercase letters: Convert account number letters to uppercase before applying the LETTER_MAP.

Quick Conversion Without Code

If you only need to convert a few RIBs, use the ibanchecker.cash RIB to IBAN converter. Enter the three RIB fields and the tool computes the Clé RIB and the FR IBAN instantly — no registration required.

Last updated: June 2026

Validate an IBAN instantly

Free IBAN checker — MOD-97 verification, bank lookup, and SEPA status across 84 countries.

Open IBAN Checker →

Related Articles