What an IBAN is made of
An IBAN (International Bank Account Number, ISO 13616) is four characters of header in front of the domestic account number:
- Country code, two letters:
GB,DE,FR. - Check digits, two digits computed from everything else. This is what the validator checks.
- BBAN, the basic bank account number: the bank, branch and account identifiers in that country's own layout.
Each country fixes its own length, from 15 characters (Norway) to 33 (Russia) in the current registry. On paper it's written in groups of four, GB82 WEST 1234 5698 7654 32; in a file or an API call it's one string with no spaces, GB82WEST12345698765432.
The mod-97 check, step by step
Take GB82 WEST 1234 5698 7654 32, a test IBAN that passes.
- Strip the spaces and upper-case it:
GB82WEST12345698765432. - Check the length against the country: GB is 22 characters, and this is 22.
- Move the first four characters to the end:
WEST12345698765432GB82. Turn each letter into a number, A = 10, B = 11, up to Z = 35. W is 32, E is 14, S is 28, T is 29, G is 16, B is 11, which gives
3214 2829 1234 5698 7654 3216 1182(spaces added to make it readable).Divide by 97 and keep the remainder. If it's 1, the checksum is valid. Here it's 1.
That number has 28 digits. A JavaScript number is exact only up to 2^53, about 9 x 10^15, which is 16 digits, so in the browser don't parse it whole. Work through it a digit at a time and keep only the remainder: remainder = (remainder x 10 + next digit) mod 97. The validator above does exactly that. Python's integers have no size limit, so this version, the book's from chapter 34 with the length and check-digit tests added, can take the whole number at once:
IBAN_LENGTHS = {"DE": 22, "FR": 27, "GB": 22, "NL": 18} # the full table is below
def valid_iban(iban: str) -> bool:
iban = iban.replace(" ", "").upper()
if not iban.isascii() or not iban.isalnum():
return False
if IBAN_LENGTHS.get(iban[:2]) != len(iban):
return False
if not iban[2:4].isdigit() or not 2 <= int(iban[2:4]) <= 98:
return False
rearranged = iban[4:] + iban[:4]
numeric = "".join(str(int(c, 36)) for c in rearranged) # A=10 ... Z=35
return int(numeric) % 97 == 1
Where the check digits come from
The bank computes them the same way, run backwards. Put 00 where the check digits go, take the remainder mod 97, and subtract it from 98. For WEST12345698765432 with GB00, the remainder is 16, and 98 - 16 = 82, which is the 82 in GB82. A remainder runs from 0 to 96, so real check digits are always between 02 and 98. The validator rejects 00, 01 and 99 even when the remainder happens to come out at 1.
What a valid checksum proves
It proves the string is well formed. Change any single character (a 3 typed as an 8, a B as an R) and the remainder stops being 1, because the change shifts the number by a multiple of a power of ten that 97, a prime, can't divide. The same argument covers two neighbouring digits swapped: the change is 9 x (difference) x a power of ten. A letter swapped with a neighbouring digit can very occasionally slip through.
It doesn't prove that the account exists, that it's open, or that it belongs to the person whose name you have. A checksum-valid IBAN can be closed, mistyped by the customer into someone else's valid number, or outside the SEPA zone. For euro transfers, Verification of Payee is the check that closes the name gap: the payer's bank compares the name against the IBAN and answers match, close match, no match or other before the money moves. Some countries also put their own check digits inside the BBAN; this validator doesn't check those, and the bank will.
A valid IBAN from a country in the table isn't automatically a SEPA address either. The registry covers countries well outside the 41-country SEPA scope, so for SEPA Direct Debit or SEPA Credit Transfer, check the country as well as the checksum.
When to validate
Twice. At onboarding, when the customer is still on the page and can fix a typo, and again when you build the payment file, because data gets edited, imported and migrated in between. Chapter 34's point is that a bad IBAN caught on your side costs nothing, while one caught by the bank comes back as a reject after you've paid for the attempt. If you collect by direct debit, a rejected collection also means a customer who thinks they've paid and hasn't.
IBAN length by country
89 countries and territories, from SWIFT's IBAN Registry, release 101. SWIFT's registry page refused automated requests on 14 November 2026, so the lengths were read from the registry file as reproduced in python-stdnum and checked country by country against iban.com's structure table. Every one matched. A country missing here has no entry in the registry, so this validator treats its IBANs as unknown.
| Country | Code | Length |
|---|---|---|
| Andorra | AD | 24 |
| United Arab Emirates | AE | 23 |
| Albania | AL | 28 |
| Austria | AT | 20 |
| Azerbaijan | AZ | 28 |
| Bosnia and Herzegovina | BA | 20 |
| Belgium | BE | 16 |
| Bulgaria | BG | 22 |
| Bahrain | BH | 22 |
| Burundi | BI | 27 |
| Brazil | BR | 29 |
| Belarus | BY | 28 |
| Switzerland | CH | 21 |
| Costa Rica | CR | 22 |
| Cyprus | CY | 28 |
| Czechia | CZ | 24 |
| Germany | DE | 22 |
| Djibouti | DJ | 27 |
| Denmark | DK | 18 |
| Dominican Republic | DO | 28 |
| Estonia | EE | 20 |
| Egypt | EG | 29 |
| Spain | ES | 24 |
| Finland | FI | 18 |
| Falkland Islands | FK | 18 |
| Faroe Islands | FO | 18 |
| France | FR | 27 |
| United Kingdom | GB | 22 |
| Georgia | GE | 22 |
| Gibraltar | GI | 23 |
| Greenland | GL | 18 |
| Greece | GR | 27 |
| Guatemala | GT | 28 |
| Honduras | HN | 28 |
| Croatia | HR | 21 |
| Hungary | HU | 28 |
| Ireland | IE | 22 |
| Israel | IL | 23 |
| Iraq | IQ | 23 |
| Iceland | IS | 26 |
| Italy | IT | 27 |
| Jordan | JO | 30 |
| Kuwait | KW | 30 |
| Kazakhstan | KZ | 20 |
| Lebanon | LB | 28 |
| Saint Lucia | LC | 32 |
| Liechtenstein | LI | 21 |
| Lithuania | LT | 20 |
| Luxembourg | LU | 20 |
| Latvia | LV | 21 |
| Libya | LY | 25 |
| Monaco | MC | 27 |
| Moldova | MD | 24 |
| Montenegro | ME | 22 |
| North Macedonia | MK | 19 |
| Mongolia | MN | 20 |
| Mauritania | MR | 27 |
| Malta | MT | 31 |
| Mauritius | MU | 30 |
| Nicaragua | NI | 28 |
| Netherlands | NL | 18 |
| Norway | NO | 15 |
| Oman | OM | 23 |
| Pakistan | PK | 24 |
| Poland | PL | 28 |
| Palestine | PS | 29 |
| Portugal | PT | 25 |
| Qatar | QA | 29 |
| Romania | RO | 24 |
| Serbia | RS | 22 |
| Russia | RU | 33 |
| Saudi Arabia | SA | 24 |
| Seychelles | SC | 31 |
| Sudan | SD | 18 |
| Sweden | SE | 24 |
| Slovenia | SI | 19 |
| Slovakia | SK | 24 |
| San Marino | SM | 27 |
| Somalia | SO | 23 |
| Sao Tome and Principe | ST | 25 |
| El Salvador | SV | 28 |
| Timor-Leste | TL | 23 |
| Tunisia | TN | 24 |
| Turkiye | TR | 26 |
| Ukraine | UA | 29 |
| Vatican City (Holy See) | VA | 22 |
| British Virgin Islands | VG | 24 |
| Kosovo | XK | 20 |
| Yemen | YE | 30 |
Questions
How do you validate an IBAN?
Strip the spaces, check the length against the country, move the first four characters to the end, turn letters into numbers (A = 10 up to Z = 35), and divide by 97. A valid IBAN leaves a remainder of 1.
Does a valid IBAN mean the account exists?
No. The checksum only proves the IBAN is well formed. The account can still be closed or belong to someone else. For euro transfers, Verification of Payee checks the name against the IBAN at the payer's bank before the money moves.
Is my IBAN sent anywhere when I use this validator?
No. The check runs in JavaScript in this page, and the input has no name, so even submitting the form doesn't put it in a URL. You can turn off your network connection and it still works.
How long is an IBAN?
It depends on the country: 15 characters in Norway, 22 in Germany and the UK, 27 in France and Italy, and 33 in Russia, the longest in the current registry. The table on this page lists all 89 countries.
What are the IBAN check digits?
The two digits after the country code, the 82 in GB82. The bank computes them by putting 00 in their place, taking the remainder mod 97 and subtracting it from 98, so they always fall between 02 and 98.