Parsing an IBAN is straightforward, but not universal
An IBAN has a standard high-level structure: country code (2 letters), check digits (2 digits), then a country-specific BBAN (basic bank account number) structure. The tricky part is the BBAN: the meaning and positions of “bank code,” “branch code,” and “account number” depend on the country.
So the reliable workflow is:
- Normalize the IBAN (remove spaces, uppercase).
- Validate country + length + checksum (MOD-97).
- Use country metadata to slice the BBAN into its components.
Step 1: Normalize before you do anything
Users paste IBANs with spaces, line breaks, or odd whitespace. Normalize by removing whitespace and uppercasing before validation or parsing. This avoids “false invalid” issues in systems that don’t normalize correctly.
Step 2: Validate first (or your parsing can mislead you)
IBAN parsing should happen after validation. If the IBAN is the wrong length for the country, or the checksum fails, any extracted “bank code” is just a substring with no guarantee it was intended to be that value.
Use the IBAN Validator to check the number before you rely on parsed components.
Step 3: Understand the three common component types
Country code + check digits
These are always present and always in the same positions:
- Country code: characters 1–2
- Check digits: characters 3–4 (MOD-97)
Bank identifier
Many countries embed a bank identifier inside the BBAN. The position and length are country-specific. Sometimes it’s all digits; sometimes it can include letters.
Branch identifier
Some countries include a branch identifier in addition to the bank identifier. Others do not. Don’t assume it exists. When it does exist, it’s also defined by country-specific positions.
Account number (or the remainder)
After bank and branch identifiers, the remainder is typically the account identifier. But again: some countries include internal check digits or sub-fields. “Account number” can be an oversimplification.
A concrete example: Germany vs UK vs France
These examples show why you can’t use a single global slicing rule.
- Germany (DE): bank identifier is an 8-digit bank code (BLZ), then a 10-digit account number.
- United Kingdom (GB): bank identifier is 4 letters (bank), branch identifier is 6 digits (sort code), then an 8-digit account number.
- France (FR): bank identifier + branch identifier are numeric (5+5), but the account part can be alphanumeric and includes a local RIB key.
If you need to sanity-check the country rules quickly, use IBAN Country Lookup and compare the expected length and BBAN format.
What you can and can’t reliably extract
Reliable
- Country code
- Check digits
- BBAN substring
- Bank/branch identifiers when the country spec defines them
Not reliable without another dataset
- Bank name from bank identifier (requires a mapping table per country)
- Account owner or existence (validation doesn’t prove ownership)
- Whether the account can receive certain transfer types (depends on bank and compliance rules)
Common parsing mistakes (and how to avoid them)
- Skipping validation: parse only after country + length + checksum checks.
- Hardcoding positions: use per-country specs, not one slicing rule.
- Assuming “account number” is numeric: some countries have alphanumeric account parts.
- Confusing display formatting with structure: spaces are for readability; they don’t define fields.
A practical workflow for teams cleaning banking data
- Validate IBANs and flag failures (Batch IBAN Validator).
- For valid IBANs, parse components (IBAN Parser).
- If you need consistent display or storage formats, normalize formatting (IBAN Formatter).
FAQs
Can I extract a bank name from an IBAN?
Not directly. You can extract a bank identifier for many countries, but turning that into a bank name requires a country-specific mapping dataset.
Why does my parsed “bank code” look different from what the bank shows?
Banks often display local routing details differently (with separators or different naming). IBAN parsing is based on country registry specs, not bank UI conventions.
Do all IBAN countries include branch codes?
No. Some include branch identifiers; others don’t. Always check the country’s BBAN format before assuming a branch field exists.
Is the BBAN the same as the account number?
No. BBAN is the entire country-specific part after the first 4 IBAN characters. It often includes bank/branch identifiers plus the account portion.
Should I parse before storing IBANs?
Store the normalized IBAN first (electronic format). Parse on demand for display or downstream logic. If you need formatting conversions, use IBAN Formatter.
What’s the safest first check before parsing?
Run the IBAN through IBAN Validator to ensure the country length and MOD-97 checksum are correct.