Banking
How IBAN Checksums Work: Understanding ISO 13616 Validation
Many countries outside the United States identify bank accounts with an IBAN, the International Bank Account Number. Unlike a typical US account number, an IBAN contains a built-in checksum, so software can catch most typing mistakes before a payment is sent. This guide explains how an IBAN is built, how the check digits are calculated under the ISO 13616 standard, and how to validate one in code.
Why the IBAN exists
Before the IBAN, every country formatted account numbers its own way, and cross-border payments were frequently delayed or returned because of small mistakes. The IBAN was created to give every account a standard, machine-checkable format. The international standard is ISO 13616, and SWIFT acts as the registration authority that publishes the national formats. More than eighty countries now use IBANs, including all of Europe, and several others in the Middle East, North Africa and the Caribbean. The United States does not use them.
The structure of an IBAN
An IBAN is made of letters and digits, up to 34 characters long, with a layout that depends on the country:
- Characters 1 and 2: the two-letter country code, such as GB, DE or FR.
- Characters 3 and 4: two check digits calculated from the rest of the number.
- The remainder: the Basic Bank Account Number (BBAN), whose format is set by each country and usually includes a bank code, a branch code and an account number.
The total length is fixed for each country. A German IBAN has 22 characters, a French one has 27, a Dutch one has 18, and Norway has the shortest at 15. Writers often show IBANs in groups of four characters for readability, but the spaces are not part of the number.
How the check digits work
The check digits use the mod-97 method, defined in the ISO 7064 standard. To verify an IBAN, you follow five steps:
- Remove spaces and convert everything to upper case.
- Move the first four characters (the country code and check digits) to the end of the string.
- Replace every letter with a number: A becomes 10, B becomes 11, and so on up to Z, which becomes 35.
- Read the result as one very long integer.
- Divide that integer by 97. If the remainder is exactly 1, the check digits are correct.
When a bank creates an IBAN, it runs the same process in reverse, placing 00 in the check digit positions, calculating the remainder, and subtracting it from 98 to get the two check digits.
A worked example
Take the widely used documentation example GB82 WEST 1234 5698 7654 32. It is an example from the standard, not a real account. Move the first four characters to the end to get WEST12345698765432GB82. Then convert letters: W is 32, E is 14, S is 28, T is 29, G is 16 and B is 11. The long number becomes:
3214282912345698765432161182 Dividing this by 97 leaves a remainder of 1, so the IBAN passes. Change any single character and the remainder changes, which is how the check catches typing errors.
Validating an IBAN in JavaScript
The integer in the example has 28 digits, more than a JavaScript number can hold exactly. Rather than using a big-number type, you can process the string piece by piece, keeping only the running remainder:
function passesIbanChecksum(input) {
const iban = String(input).replace(/\s/g, "").toUpperCase();
if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(iban)) return false;
const rearranged = iban.slice(4) + iban.slice(0, 4);
let remainder = 0;
for (const ch of rearranged) {
const value = ch >= "A" ? ch.charCodeAt(0) - 55 : Number(ch);
remainder = Number(String(remainder) + String(value)) % 97;
}
return remainder === 1;
} This works because dividing a long number digit by digit is equivalent to carrying the remainder forward. If you want to learn more about the language features used here, the MDN JavaScript documentation is a reliable reference.
What the checksum does not prove
A passing mod-97 check tells you the characters are consistent with each other. It does not prove that the account exists, that it is open, or that it belongs to the person you intend to pay. A single number can also pass the checksum yet be wrong for its country, so good validators add further checks:
- Country code. The two letters must belong to a country that uses IBANs.
- Length. The total length must match the length registered for that country.
- BBAN pattern. The remainder must match the country’s layout of letters and digits.
- National check digits. Some countries also build their own checksum into the BBAN, which you can verify with country-specific rules.
Mod-97 is strong at catching ordinary mistakes: it detects every single-character error and nearly all swaps of adjacent characters. Even so, it is a format check, and confirming an account always involves the bank.
Practical tips for developers
- Normalize first. Accept spaces and mixed case, then store the compact upper-case form.
- Keep a table of country lengths. Update it from the official registry, because new countries and formats are added from time to time.
- Do not truncate. Allow input fields to hold at least 34 characters.
- Write helpful errors. Say what is wrong, for example “This country uses 22 characters, you entered 21”, rather than “Invalid IBAN”.
- Pair it with a BIC or bank name lookup where needed. Within the SEPA area an IBAN alone is usually enough, but other regions may still require a SWIFT/BIC code.
You can read the official registry information on the SWIFT website.
IBANs and Tvalidora
Our tools currently focus on US formats, namely the Luhn check for card numbers and the weighted checksum for US routing numbers. Support for international bank codes such as the IBAN is on our roadmap, and our FAQ says so plainly. In the meantime, you can try the existing validator to see how a real-time checksum feels in practice.
Key takeaways
An IBAN is a country code, two check digits and a national account identifier, with a fixed length for each country. The mod-97 calculation moves the first four characters to the end, converts letters to numbers and checks that the remainder is 1. It is simple, fast and excellent at catching typos, but it validates structure only. Combine it with country length and pattern checks, and rely on the bank to confirm that an account is real.
Put it into practice: check the format of a card, routing or account number with the Tvalidora validator, look up an area code or zip code with the US Checker, or read the FAQ to see exactly what a “valid” result means. Tvalidora checks number format only, and never stores what you enter.