Skip to content
Banking

IBAN Format by Country: Lengths, Structure and How to Validate Any IBAN

PAYATE Teamยท ยท 7 min read
IPAYATE

The International Bank Account Number (IBAN) is the standard way to identify a bank account for cross-border payments in Europe, the Middle East and a growing list of other countries. It was designed to cut down on misrouted and rejected transfers, and it does this with two features: a fixed, country-specific structure, and built-in check digits that catch most typing errors.

If you are new to IBANs, start with our introduction, What is an IBAN?. This article goes one level deeper. It explains how an IBAN is built, why lengths differ by country, how to read the official format notation, and how to validate an IBAN yourself with the MOD-97 algorithm, using a worked example you can check by hand.

Anatomy of an IBAN

Every IBAN, whatever the country, follows the same three-part pattern defined in the ISO 13616 standard:

  1. Country code (2 letters): the ISO 3166-1 alpha-2 code of the country where the account is held, such as DE for Germany or GB for the United Kingdom.
  2. Check digits (2 digits): calculated from the rest of the IBAN using the MOD-97 algorithm. They let software detect most errors before a payment is sent.
  3. BBAN (Basic Bank Account Number): the domestic account identifier, in a fixed format chosen by each country. It usually contains a bank code, often a branch code, and the account number, and sometimes a national check digit.

Take the standard German example, DE89 3704 0044 0532 0130 00:

  • DE is the country code.
  • 89 are the check digits.
  • 37040044 is the 8-digit bank code (Bankleitzahl).
  • 0532013000 is the 10-digit account number.

The spaces are only there for readability. In printed form, IBANs are written in groups of four characters, but the electronic form used in payment files and APIs has no spaces. You can see the full breakdown for Germany on our German IBAN format page.

Why IBAN lengths differ by country

The country code and check digits are always four characters, but the BBAN is whatever length each country's domestic system needs. Within a single country the length is fixed, which makes length one of the quickest validation checks. Across countries it varies widely:

  • Norway uses one of the shortest IBANs, at 15 characters.
  • Belgium uses 16 and the Netherlands 18.
  • Germany and the United Kingdom both use 22, but with very different structures.
  • France and Italy use 27.
  • Malta uses 31, among the longest in use.

The standard allows a maximum of 34 characters, and a small number of countries use IBANs a little longer than Malta's. Because these details are maintained in the official IBAN registry and new countries join from time to time, any validator should load its country rules from up-to-date reference data rather than a list hardcoded years ago. Our IBAN format by country pages list the length and structure for each country.

Reading the BBAN format notation

The IBAN registry describes each country's format with a compact notation. Each part is written as a length, an optional exclamation mark, and a character type:

  • n: digits only (0โ€“9)
  • a: upper-case letters only (Aโ€“Z)
  • c: alphanumeric, upper-case letters or digits
  • !: the length is fixed. Without it, the number is a maximum length.

For IBAN structures, every part has a fixed length. For example, the United Kingdom's BBAN is 4!a6!n8!n: four letters for the bank identifier, a six-digit sort code, and an eight-digit account number. So in GB29 NWBK 6016 1331 9268 19, NWBK is the bank code, 601613 is the sort code and 31926819 is the account number. See the UK IBAN format page for details.

France's BBAN is 5!n5!n11!c2!n: a five-digit bank code, a five-digit branch code, an eleven-character account number that may contain letters, and a two-digit national check key. That is why a French IBAN can legitimately contain a letter in the middle, as in the registry example FR14 2004 1010 0505 0001 3M02 606. More on the French IBAN format page.

IBAN formats for common countries

The table below lists the total length, BBAN structure and the published example IBAN for a selection of countries. All examples are standard sample IBANs from the registry, not real customer accounts, and each passes the MOD-97 check.

CountryCodeLengthBBAN formatExample
NorwayNO154!n6!n1!nNO93 8601 1117 947
BelgiumBE163!n7!n2!nBE68 5390 0754 7034
NetherlandsNL184!a10!nNL91 ABNA 0417 1643 00
GermanyDE228!n10!nDE89 3704 0044 0532 0130 00
United KingdomGB224!a6!n8!nGB29 NWBK 6016 1331 9268 19
United Arab EmiratesAE233!n16!nAE07 0331 2345 6789 0123 456
SpainES244!n4!n1!n1!n10!nES91 2100 0418 4502 0005 1332
Saudi ArabiaSA242!n18!cSA03 8000 0000 6080 1016 7519
FranceFR275!n5!n11!c2!nFR14 2004 1010 0505 0001 3M02 606
ItalyIT271!a5!n5!n12!cIT60 X054 2811 1010 0000 0123 456
MaltaMT314!a5!n18!cMT84 MALT 0110 0001 2345 MTLC AST0 01S

For Gulf countries, see the dedicated Saudi Arabia IBAN format and UAE IBAN format pages. Formats are occasionally updated, so confirm against the official registry or your bank if you are building a production system.

How to validate an IBAN with MOD-97

The check digits are verified with the ISO 7064 MOD 97-10 algorithm. A valid IBAN, rearranged and converted to a number as described below, always leaves a remainder of exactly 1 when divided by 97. Here is the full process using DE89 3704 0044 0532 0130 00.

Step 1: Clean up and check the length

Remove spaces and convert to upper case: DE89370400440532013000. This is 22 characters, which matches the required length for Germany. If the length is wrong for the country code, the IBAN is invalid and you can stop here.

Step 2: Move the first four characters to the end

Take DE89 from the front and append it to the end:

370400440532013000DE89

Step 3: Replace letters with numbers

Each letter becomes a two-digit number: A = 10, B = 11, and so on up to Z = 35. Here D = 13 and E = 14, so DE becomes 1314:

370400440532013000131489

Step 4: Calculate the remainder modulo 97

This 24-digit number is too large for standard 64-bit integers, so either use an arbitrary-precision library or process it in pieces. The piece-by-piece method works because you can carry the remainder forward:

  1. Take the first 9 digits: 370400440 mod 97 = 23.
  2. Prefix the remainder to the next 7 digits: 235320130 mod 97 = 70.
  3. Prefix again to the next 7 digits: 700013148 mod 97 = 38.
  4. Prefix to the last remaining digit: 389 mod 97 = 1.

The final remainder is 1, so the IBAN is valid. If a single digit had been mistyped, the remainder would almost certainly be something other than 1.

In code, the simplest safe approach processes one digit at a time:

function iban_is_valid(string $iban): bool {
    $iban = strtoupper(preg_replace('/\s+/', '', $iban));
    if (!preg_match('/^[A-Z]{2}[0-9]{2}[A-Z0-9]+$/', $iban)) return false;
    $r = substr($iban, 4) . substr($iban, 0, 4);
    $rem = 0;
    foreach (str_split($r) as $ch) {
        $v = ctype_alpha($ch) ? (string)(ord($ch) - 55) : $ch;
        foreach (str_split($v) as $d) {
            $rem = ($rem * 10 + (int)$d) % 97;
        }
    }
    return $rem === 1;
}

This checks the character set and the check digits only. A complete validator should also check the length and BBAN structure for the specific country, which requires per-country reference data.

Calculating check digits

To generate check digits for a new IBAN, replace them with 00, run steps 2 to 4, and subtract the remainder from 98. For the German example, 370400440532013000131400 mod 97 = 9, and 98 โˆ’ 9 = 89, giving the check digits 89.

Common IBAN validation mistakes

  • Stopping at MOD-97: an IBAN can pass the checksum and still have the wrong length or structure for its country. Check length and format first.
  • Using floating-point or 32-bit math: the converted number is far too large. Converting it to a float silently loses precision and produces wrong results.
  • Rejecting spaces or lower case: users paste IBANs in many forms. Normalise first by stripping spaces and upper-casing, then validate.
  • Hardcoding an old country list: countries join the IBAN system and formats occasionally change. Keep reference data updated.
  • Treating valid as existing: a valid IBAN only means the format and check digits are correct. It does not prove the account exists, is open, or belongs to the named recipient. Only the bank, or a dedicated verification service, can confirm that.
  • Ignoring national check digits: some countries, such as France and Spain, include their own check digits inside the BBAN. Stricter validators verify these too.

IBAN vs SWIFT/BIC

IBANs and SWIFT codes are often requested together, but they identify different things. The IBAN identifies a specific account. A SWIFT code, also called a BIC (Business Identifier Code), identifies a bank, or a specific branch of it. A BIC is 8 or 11 characters long: a four-letter institution code, a two-letter country code, a two-character location code, and an optional three-character branch code.

For payments within the SEPA zone, the IBAN alone is generally enough, and banks are not supposed to require a BIC from customers. For international transfers outside SEPA, you will usually need both: the BIC to route the payment to the right bank and the IBAN to credit the right account. You can look up bank identifiers in our SWIFT code directory.

Check an IBAN quickly

For a quick check of a single IBAN, use our free IBAN tools, which check the length, structure and check digits for the country. As with any format validator, a passing result means the IBAN is well-formed, not that the account exists, so always confirm payment details with the recipient before sending money.

Frequently asked questions

How long is an IBAN?
It depends on the country, but the length is fixed within each country. Norway uses 15 characters, Belgium 16, Germany and the United Kingdom 22, France and Italy 27, and Malta 31. The standard allows up to 34 characters.
How does the IBAN check digit validation work?
Move the first four characters to the end, replace each letter with a number from 10 to 35, and calculate the remainder when the resulting number is divided by 97. A valid IBAN always gives a remainder of 1.
If an IBAN passes validation, does the account exist?
No. Validation only confirms the IBAN has the right length, structure and check digits. It cannot tell you whether the account is open or who owns it. Only the bank or a dedicated verification service can confirm that.
What is the difference between an IBAN and a SWIFT/BIC code?
An IBAN identifies a specific bank account, while a SWIFT or BIC code identifies a bank or one of its branches. SEPA payments usually need only the IBAN, while many international transfers need both.
Can an IBAN contain letters after the country code?
Yes, in some countries. The BBAN format for countries such as the United Kingdom, the Netherlands, France, Italy and Malta includes letters or alphanumeric parts, so letters inside the IBAN are valid there.

Try the tools

P
Written by PAYATE Team

The PAYATE team builds free tools for merchants and developers.

More PAYATE tools