A supplier sends an invoice with new bank details. A customer types their account number into a direct debit form. Your finance team imports a spreadsheet of 800 payee records before a payment run. In each case one wrong character can send money to the wrong place, or cause a transfer to bounce days later with fees and a confused conversation.
The International Bank Account Number (IBAN) was designed with this in mind: two check digits catch nearly all typing mistakes before a payment is made. This guide explains how an IBAN is built, how the mod-97 check works, how to validate IBANs by hand, in the browser or in code, and what a validation cannot tell you.
How an IBAN is put together
Every IBAN follows the same outer pattern, defined in ISO 13616:
| Part | Example (UK) | Meaning |
|---|---|---|
| Country code | GB |
Two-letter ISO country code |
| Check digits | 82 |
Calculated from the rest of the IBAN |
| BBAN | WEST12345698765432 |
The domestic account number, in a country-specific format |
The BBAN (basic bank account number) is where countries differ. In the UK it is a 4-letter bank code, a 6-digit sort code and an 8-digit account number. In Germany it is an 8-digit bank code followed by a 10-digit account number. Each country has a fixed total length:
| Country | Length | Example |
|---|---|---|
| Belgium | 16 | BE68 5390 0754 7034 |
| Netherlands | 18 | NL91 ABNA 0417 1643 00 |
| Switzerland | 21 | CH93 0076 2011 6238 5295 7 |
| Germany | 22 | DE89 3704 0044 0532 0130 00 |
| United Kingdom | 22 | GB82 WEST 1234 5698 7654 32 |
| Spain | 24 | |
| France | 27 | FR14 2004 1010 0505 0001 3M02 606 |
| Italy | 27 |
The groups of four are only the print format for humans. Payment files and APIs use the electronic format, with no spaces.
How the mod-97 check digits work
The check digits make the whole IBAN, read as a number in a particular way, leave a remainder of 1 when divided by 97. To check an IBAN:
- Remove spaces and convert to upper case.
- Move the first four characters (country code and check digits) to the end.
- Replace each letter with two digits: A = 10, B = 11, and so on to Z = 35.
- Divide the resulting number by 97. If the remainder is 1, the IBAN passes.
For GB82WEST12345698765432, step 2 gives WEST12345698765432GB82, and step 3 turns it into a number of more than 25 digits. That is too large for ordinary floating-point arithmetic, so implementations process it a few digits at a time, carrying the remainder forward. This is the ISO 7064 mod 97-10 scheme, and it detects all single-character errors and nearly all swaps of adjacent characters.
To create check digits, the bank sets them to 00, runs the same calculation and subtracts the remainder from 98.
Validate an IBAN with our tool
The IBAN Validator runs every check in your browser. No bank or external service is contacted.
- Type or paste an IBAN into the IBAN box, with or without spaces, or click one of the country examples to see how a valid one looks.
- Read the Valid IBAN or Invalid IBAN badge and the individual checks for country code, length and check digits.
- If the check fails, note the check digits the rest of the number would need. A mismatch with what you typed points to a typo somewhere in the BBAN.
- Review the breakdown table: country code, check digits and, for about forty common countries, the bank code, branch or sort code and account number inside the BBAN.
- Copy the Print format for documents or the Electronic format for payment files.
- To check a spreadsheet column, open Validate a list of IBANs and paste up to 1,000 IBANs, one per line, to get valid and invalid counts.
Validating IBANs in code
This JavaScript handles the long number by keeping only the running remainder, so it needs no big-number library. It also shows how check digits are calculated.
// Remainder of a long alphanumeric string modulo 97 (A=10 ... Z=35)
function mod97(str) {
let remainder = 0;
for (const ch of str) {
const value = ch >= "A" ? ch.charCodeAt(0) - 55 : Number(ch);
remainder = Number(String(remainder) + value) % 97;
}
return remainder;
}
function ibanValid(input) {
const iban = input.replace(/\s+/g, "").toUpperCase();
if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(iban)) return false;
return mod97(iban.slice(4) + iban.slice(0, 4)) === 1;
}
// Check digits for a country code + BBAN
function ibanCheckDigits(country, bban) {
const cd = 98 - mod97(bban + country + "00");
return String(cd).padStart(2, "0");
}
console.log(ibanValid("GB82 WEST 1234 5698 7654 32")); // true
console.log(ibanValid("GB82 WEST 1234 5698 7654 23")); // false (last two digits swapped)
console.log(ibanCheckDigits("DE", "370400440532013000")); // "89"
For production, add a table of country codes and lengths (the SWIFT IBAN registry is the authoritative source) so that an IBAN with the right checksum but the wrong length for its country is also rejected. Many languages have maintained IBAN libraries that include this table and the per-country BBAN formats.
In a spreadsheet
Spreadsheets struggle with mod-97 on long numbers because they lose precision beyond about 15 digits. You can split the calculation into chunks with helper columns, but for more than a handful of rows, pasting the column into a bulk validator or using a script is faster and less error-prone. If your data needs cleaning first, a Remove Duplicate Lines pass helps before validation.
What IBAN validation cannot tell you
This is the part that protects you from the expensive mistakes.
- It does not confirm the account exists. A correctly formed IBAN may never have been issued or may belong to a closed account.
- It does not confirm the account holder. A valid IBAN tells you nothing about whose account it is. Some banking systems offer a separate name-matching service at payment time; use it where available.
- It does not give you the BIC. Finding the bank's BIC/SWIFT code needs a bank directory. For some countries the bank code inside the BBAN hints at it, but it is not a substitute.
A common fraud pattern is an email, apparently from a known supplier, announcing new bank details. The new IBAN will usually be perfectly valid. Always confirm changed payment details through a contact method you already hold, such as a known phone number, not the one in the email.
Troubleshooting failed validations
Wrong length
Characters were dropped or duplicated, or the country code is wrong. Compare the length with the country's required length before hunting for individual digits.
Letter O versus digit 0
Several countries allow letters in the BBAN, so O and 0, or I and 1, get confused when IBANs are read from paper. Check against the original document.
Pasted from a PDF or email
Invisible characters, such as non-breaking spaces, can sneak in. Paste into a plain text editor first. Some systems also reject lower-case letters, so convert with a Case Converter or in your code.
It validates but the payment still fails
The structure is fine but the account may be closed or the name may not match. Contact the payee directly. A structural check, like a Credit Card Validator for card numbers, only catches typing errors.
Frequently asked questions
Does a valid IBAN mean the account exists?
No. It only means the IBAN is correctly formed for its country and its check digits are consistent. Only the receiving bank can confirm the account and its holder.
Do all countries use IBANs?
No. IBANs are used across Europe and in many countries in the Middle East, North Africa and Latin America, but some major economies, including the United States, use their own domestic account and routing numbers instead.
Should I store IBANs with spaces?
Store the electronic format without spaces and upper case, and add spaces only when displaying it. That keeps comparisons and deduplication reliable.
Can two different IBANs have the same check digits?
Yes. Check digits are only two digits, so many IBANs share them. They are designed to catch typing errors in a given IBAN, not to be unique.
Is the IBAN the same as the account number?
No. The domestic account number is part of the BBAN inside the IBAN, alongside the bank code and sometimes a branch code and national check digits.