HomeGuidesComprehensive Guide to IBAN Validation and Check Digits › How IBAN Validation Works: Modulo 97 Checksum

How IBAN Validation Works: Modulo 97 Checksum

IBAN validation uses the ISO 7064 MOD-97-10 algorithm to confirm the mathematical integrity of an account string using modulo-97 division.

The Modulo 97 Mathematics Explained

The validation process follows a specific mathematical sequence: 1. **Reorganization:** Move the country code and check digits from the start to the end of the IBAN. For example, the first four characters are shifted to the end of the string. This puts the check digits at the very end of the routing value. 2. **Letter Conversion:** Convert all alphabetic letters to digits (A=10, B=11, ..., Z=35). This replaces every letter in the string with its corresponding two-digit numeric value, standardizing the alphanumeric input into a pure numeric sequence. 3. **Integer Modulo:** Perform division by 97 on the resulting integer string. If the remainder equals 1, the checksum is valid. This modulo operation validates the entire account sequence against keying errors. Because 97 is a prime number, this specific modulo operation provides excellent protection against adjacent transpositions and single-character substitutions, catching keying errors before they reach clearing rails. This mathematical property is defined under the ISO 7064 standard, ensuring that banks do not need to query a central database to verify if a code is syntactically sound. The MOD-97 checksum is the mathematical foundation of the IBAN standard. To validate the check digits, the country code and check digits are moved to the end of the string. The alphanumeric characters are converted to numbers, and the resulting integer is divided by 97. A remainder of exactly 1 confirms that the check digits match the structure, indicating validity.

Worked Example: Computing a Real IBAN

Let's validate the sample IBAN: `GB82WEST12345698765432` step-by-step: 1. **Reorder the string:** Move the first 4 characters (`GB82`) to the end. The string becomes: `WEST12345698765432GB82`. 2. **Convert letters to numbers:** Replace letters with their numeric equivalents (W=32, E=14, S=28, T=29, G=16, B=11). The converted string is: `3214282912345698765432161182`. 3. **Apply Modulo 97:** Divide this massive number by 97. We compute: `3214282912345698765432161182 % 97`. 4. **Check the result:** The remainder of this division is exactly `1`. Since the remainder is `1`, the checksum is mathematically valid, proving the account format is structurally correct. If a user made a typo and entered `GB82WEST12345698765433` (changing the last digit to 3), the converted string would be `3214282912345698765433161182`. Running `3214282912345698765433161182 % 97` yields a remainder of `2`, causing the validation to fail immediately. This concrete example demonstrates how the ISO 7064 algorithm isolates errors, checking entry string integrity and preventing misdirected transactions. It provides developers with a clear blueprint to construct test cases, ensuring their validation libraries handle border inputs correctly. The worked example of the IBAN `GB82WEST12345698765432` demonstrates the step-by-step math. Moving `GB82` to the end yields `WEST12345698765432GB82`. Converting letters (W=32, E=14, S=28, T=29, G=16, B=11) results in `3214282912345698765432161182`. Dividing by 97 yields a remainder of 1, proving the code structure is mathematically correct.

Handling Large Integers in Code

Because an IBAN string can generate a number up to 70 digits long, standard integer variables can cause buffer overflows. Modern validation engines use arbitrary-precision arithmetic (like JavaScript BigInt or Python Decimal math) to parse these strings safely. In JavaScript, calling `BigInt("3214282912345698765432161182") % 97n` returns `1n`. Without this BigInt support, standard floats will lose precision on the last 15 digits, yielding incorrect check digits and failing valid accounts. Developers must be careful when implementing these checks in older browser engines that lack native BigInt support. In such environments, custom string-based modulo algorithms (which perform division chunk-by-chunk) are required to verify the check digits without losing precision, illustrating the technical nuances of global banking integration. These custom parsers split the large integer string into smaller segments of 9-12 digits, calculating the modulo sequentially, ensuring backward compatibility with legacy devices and web systems. This localized processing ensures that clients running outdated operating systems can still validate payment credentials without facing script exceptions, preserving user experience across all digital touchpoints. Parsing large integers requires specialized libraries in many programming environments. Because the converted numeric string can be up to 70 digits long, standard integer types will overflow. Developers use arbitrary-precision libraries (like BigInt in JavaScript or Decimal in Python) to execute the modulo-97 calculation without losing data precision, preventing false rejections.

Related topics

What is an IBAN (International Bank Account Number)?

Understand what an International Bank Account Number (IBAN) is, how it is structured under ISO 13616, and its role in routing cross-border transfers.

IBAN Formats, Lengths & Masks by Country

Access the complete registry of IBAN formats, character lengths, and structure masks across participating countries.

Frequently asked questions

What is Modulo 97?
Modulo 97 is the division algorithm defined by ISO 7064 MOD-97-10 used to validate IBANs. It calculates the remainder after dividing a large integer by 97, confirming validity if the remainder is exactly 1. It is a highly reliable error-detection method widely adopted by international clearing houses.
Does a valid checksum guarantee the account is active?
No. A valid checksum confirms the IBAN structure and check digits are correct, but does not verify if the account is currently open or registered to an active bank client. A bank account lookup is required for that. Checksum checks only verify format integrity and cannot verify client balance or status.
Why does the check digits division require a prime number?
The number 97 is prime, which provides optimal distribution and collision avoidance in modular arithmetic. This prime modulo ensures that common entry errors, like single-digit offsets or adjacent transpositions, are caught. It maximizes the mathematical detection rate across all alphanumeric combinations.
How do you calculate the check digits for a new IBAN?
To calculate new check digits, construct the BBAN, append the country code and '00', convert to numeric digits, divide by 97, subtract the remainder from 98, and pad with leading zeros if the result is under 10. This ensures the final IBAN resolves to a remainder of 1 when run through the standard parser.
What error types does MOD-97 catch?
MOD-97 catches single-digit typos, adjacent transpositions (swapping 2 and 3), double transpositions, and formatting length errors, ensuring a high capture rate of manual data entry typos. It is the primary defense against payment routing errors, keeping exception rates low.

Sources & references

← Back to Comprehensive Guide to IBAN Validation and Check Digits

Copied code: