How IBAN Check Digits Are Calculated, Step by Step
Mistype one digit of a bank account number and money can bounce or, worse, land in the wrong place. The International Bank Account Number solves much of this with two small check digits right after the country code. Here is exactly how those digits are calculated, why the method catches most typos, and how developers can validate IBANs properly without ever touching a real customerโs account details.
What an IBAN is made of
An IBAN has three parts:
- Country code โ two letters, such as DE, GB or FR.
- Check digits โ two digits from 02 to 98.
- BBAN โ the Basic Bank Account Number, whose layout is set by each country and usually contains a bank or branch code plus the account number.
The total length is fixed per country: 22 characters for Germany, 18 for the Netherlands, 27 for France and up to 34 in the standard. On paper, IBANs are printed in groups of four for readability; electronically they are one unbroken string.
Calculating the check digits with mod 97
The check digits follow ISO 7064 MOD 97-10. To create them:
- Write the country code, then
00as placeholder check digits, then the BBAN. - Move the first four characters to the end of the string.
- Replace every letter with two digits: A = 10, B = 11 โฆ Z = 35.
- Treat the result as one big number and find its remainder when divided by 97.
- Subtract that remainder from 98. The answer, padded to two digits, is the check number.
For example, if the remainder in step 4 is 16, the check digits are 98 โ 16 = 82.
Validating an existing IBAN
Validation reuses the same steps with the real check digits left in place: rearrange, convert the letters, divide by 97. A valid IBAN always leaves a remainder of exactly 1.
Why mod 97 catches typos so well
Because 97 is prime and the converted number is long, the method detects every single-character error and almost every case of two neighboring characters being swapped โ the two mistakes people make most often when typing. It cannot prove that an account exists, though. A perfectly valid IBAN may still belong to nobody, so payment systems combine the checksum with a bank-side lookup.
Most programming languages cannot hold the converted number in a normal integer, so validators process it in chunks: take a few digits, compute the remainder, prepend it to the next chunk and repeat.
Generating test IBANs with RandNow
The Random IBAN Generator builds numbers that already pass the mod-97 check, which makes it easy to test the happy path and then break things on purpose:
- Choose a country โ Germany, the United Kingdom, the Netherlands, France, Belgium, Switzerland, Austria or Ireland โ or a random mix.
- Pick how many you need, up to 50 per click.
- Decide on the format: grouped in blocks of four, or one string without spaces.
- Generate and check the label on each result, which shows its country and character count.
- Copy or export the list, then edit a few by hand to create deliberately invalid samples.
The account numbers are random and belong to no real customer. They are strictly test data for forms, validators and databases โ never for real payments.
A validation checklist for payment forms
- Strip spaces and convert to uppercase before checking.
- Confirm the country code is supported and the length matches that country.
- Allow only letters and digits in the BBAN.
- Run the mod-97 check and show a friendly message when it fails.
- Display the result back in groups of four so users can compare it with their bank card or statement.
Where IBANs are used today
The IBAN standard was first published in the late 1990s to make cross-border payments in Europe less error-prone. It became essential with the Single Euro Payments Area (SEPA), where IBANs replaced national account formats for euro transfers, direct debits and salary payments. Today dozens of countries across Europe, the Middle East and beyond use them, while others, including the United States, still rely on their own domestic systems.
For developers this means one validation routine can cover many countries, as long as you keep a table of each countryโs length and BBAN layout up to date. It also means international users may paste an IBAN where you expected a local account number, so clear labels and helpful error messages matter as much as the math.
Pro tips
- Test both formats โ with and without spaces โ because users paste both.
- Change one digit of a valid test IBAN to confirm your form rejects it.
- Swap two neighboring digits to make sure transposition errors are caught.
- Never log full IBANs from real users; mask all but the last few characters.
Frequently asked questions
Can the IBAN check digits be 00 or 01?
No. The calculation always produces a value from 02 to 98, so 00, 01 and 99 indicate an invalid IBAN.
Does a valid checksum mean the account exists?
No. The checksum only proves the number is well formed. Only the bank or a payment provider can confirm that an account is real and open.
Is an IBAN the same as a SWIFT or BIC code?
No. The IBAN identifies an individual account, while the BIC identifies the bank itself. Some international transfers ask for both.