IBAN structure, check digits and data validation
Check an IBAN’s structure and length, follow a worked MOD97 example and resolve errors without guessing digits. Distinguish checksum validation from confirming the recipient.

In this article
Checking an IBAN means separating two questions: do its characters meet the format and checksum rules, and do they identify the intended account and recipient? Passing the first check does not answer the second.
An IBAN is an international bank account identifier. Its check digits help detect typing errors, but they do not prove that the account exists, remains open or belongs to the person requesting payment. Nor do they confirm the balance, authorisation or absence of fraud.
Read the structure without applying another country’s length
An IBAN contains a two-letter country code, two international check digits and a national account identifier called the BBAN. It can contain up to 34 alphanumeric characters, but each national format has a fixed length and its own pattern. The maximum of 34 is not a target length.
For example, a Spanish IBAN has 24 characters and a German IBAN has 22. The BBAN can include letters where the national format permits them: it should not always be treated as a string of digits.
This official demonstration example shows how the parts fit together. It is for educational use only: do not use it as a payment destination.
ES91 2100 0418 4502 0005 1332
Here, ES identifies Spain and 91 is the pair of international check digits. The BBAN breaks down as follows: 2100 identifies the bank; 0418 identifies the branch; 45 is the pair of national check digits; and 0200051332 is the account number. The national check digits 45 are distinct from the international check digits 91.
Spaces group the characters in sets of four to make them easier to read; those groups do not necessarily mark the boundaries between components. In electronic format, the example is written as ES9121000418450200051332.
Prepare and check the data before calculating
Start with a reliable bank document or banking channel and keep the IBAN as text, preserving every zero. Remove spaces known to be used for presentation and, if it appears as a separate label, the word “IBAN”. Convert lowercase Latin letters to uppercase without otherwise changing the content.
Next, check the characters: the electronic format uses letters from A to Z and digits from 0 to 9. If you find unfamiliar symbols, characters from other alphabets or possible confusion between O and 0, or between I and 1, return to the original document. Do not delete or replace characters based on a guess; request an unambiguous copy. Avoid entering real bank details into public validation tools.
Once the string is prepared, check that it begins with two country-code letters and two check digits. Then compare the country code, exact length and permitted positions for letters and numbers against the current registered national format, or ask your bank to perform that check. Having fewer than 34 characters is not enough. Do not try to turn a local account number into an IBAN simply by adding a prefix, either.
Only after these checks have passed does it make sense to calculate the international checksum. Any additional BBAN checks that apply must be performed separately: MOD97 does not replace all national validation rules.
Validate IBAN check digits with MOD97
The procedure is to move the first four characters to the end, convert all letters to numbers and calculate the remainder after division by 97. The conversion follows the 26-letter Latin alphabet: A = 10, B = 11, through to Z = 35. Any letters within the BBAN must also be converted.
Applied to the example:
- String without spaces:
ES9121000418450200051332. - First four characters moved to the end:
21000418450200051332ES91. - Conversion of
E = 14andS = 28:21000418450200051332142891. - Remainder after dividing that number by 97: 1. The international checksum check passes.
To reproduce the calculation without handling such a long number all at once, split the numeric string into blocks: 210004 | 184502 | 000513 | 321428 | 91. Calculate the remainder for the first block, then place that remainder before the next block, preserving the block’s zeros:
| Step | Number divided by 97 | Remainder |
|---|---|---|
| First block | 210004 |
96 |
Append 184502 to the previous remainder |
96184502 |
78 |
Append 000513 |
78000513 |
0 |
Append 321428 |
0321428 |
67 |
Append 91 |
6791 |
1 |
Software can also process the numeric string one digit at a time. Start with a remainder of r = 0 and, for each digit d, calculate r = (10 × r + d) mod 97. This avoids converting the entire string into a floating-point number that could lose precision. The final remainder must be 1.
Now introduce a hypothetical typing error: change only the IBAN’s last digit from 2 to 3. The input becomes ES9121000418450200051333; after moving the first four characters and converting the letters, the result is 21000418450200051333142891. Its remainder when divided by 97 is 28, so the checksum check fails, even though it still has 24 characters and follows the Spanish format.
The failure does not reveal which digit the person intended to enter. Do not recalculate the check digits to make the input pass: that would restore mathematical consistency, not necessarily identify the correct account.
Resolve failures and confirm the recipient
If the length, country code or permitted characters do not match the required format, request the complete IBAN again and compare it with the original bank record. Do not add zeros or remove digits to make the length fit. If the format is correct but MOD97 fails, copy it again from that record and repeat the check. If it still fails, ask the bank or recipient for clarification through a trusted channel.
If a form rejects a national format you have confirmed is correct, contact the form provider or your bank. Do not alter the number to fit the form’s restrictions.
Finally, confirm the recipient independently. Suppose a regular supplier emails you with a change of bank account and the new IBAN passes MOD97. That result does not authenticate the change: call the usual number you already had, not the one in the message, before updating the details or making a payment.
Where your bank offers beneficiary verification, review its response on whether the name matches the account. A close match, a mismatch or an inability to verify requires clarification before proceeding; none is equivalent to a confirmed match. Even a match does not, by itself, establish that the payment request is legitimate.
If you have already sent a transfer and discover an error or suspect fraud, contact your bank immediately and provide the transaction details. Do not assume the money can be recovered.


