BankCheck
HomeIBANRouting NumberSort CodeSWIFT/BICGeneratorGuides
Home
IBAN
Routing Number
Sort Code
SWIFT/BIC
Generator
Guides

BankCheck

Validate any bank number instantly. Free and 100% client-side.

Your data never leaves the browser

Formats

IBAN40+ countriesRouting NumberUnited StatesSort CodeUK & IrelandSWIFT/BICWorldwide

Info

IBAN GeneratorTransfer GuidesGlossaryGuidesCompareAlternativesAboutPrivacy PolicyTerms of UseAPI Docs

BankCheck checks whether a number could be valid based on format, length, and checksum rules. It does not verify that an account exists or confirm who it belongs to. Always confirm account details with your bank before making a payment.

© 2026 BankCheck

How to Validate Bank Details in Code

8 min read|Updated March 25, 2026

Validating bank details in your application prevents failed payments, reduces support tickets, and gives users immediate feedback when they enter incorrect account numbers. Whether you are building a checkout flow, a payroll system, or a payment integration, catching invalid IBANs, routing numbers, and sort codes at the point of entry saves time and money for everyone involved. This guide walks through the BankCheck free API, validation algorithms, error handling best practices, and testing strategies. For the full API reference, see our API documentation.

Why Validate in Code?

Manual verification of bank details does not scale. When a user enters an IBAN, routing number, or sort code into your application, you need to verify it programmatically before submitting a payment. Here is why this matters:

  • Prevent failed payments. Banks reject payments with invalid account numbers. Each rejection triggers return fees, delays, and manual intervention. Catching errors before submission eliminates this entirely.
  • Improve user experience. Telling a user their IBAN is two characters too short the moment they type it is far better than telling them three days later when the payment bounces.
  • Reduce support tickets. A significant percentage of payment-related support requests stem from incorrectly entered bank details. Client-side validation eliminates these at the source.
  • Comply with regulations. Financial regulations in many jurisdictions require reasonable measures to verify payment details before processing. Format validation is a baseline expectation.

BankCheck Free API

BankCheck provides a free validation API that requires no signup, no API key, and no authentication. CORS is enabled for all origins, making it usable directly from browser-based applications. The API validates IBANs, US routing numbers, UK sort codes, and SWIFT/BIC codes.

The endpoint accepts both GET and POST requests:

  • GET: /api/v1/validate?q=DE89370400440532013000
  • POST: /api/v1/validate with JSON body { "input": "DE89370400440532013000" }

The API auto-detects the format (IBAN, routing number, sort code, or SWIFT/BIC) from the input. You can also pass an optional format parameter to skip auto-detection. See the full API documentation for response schemas and all supported parameters.

API Examples

Below are working examples for the three most common integration patterns. Each validates a German IBAN and shows the expected request and response structure.

curl

curl -X POST https://bankcheck.io/api/v1/validate -H "Content-Type: application/json" -d '{ "input": "DE89370400440532013000" }'

The response includes apiVersion, processingTimeMs, and a result object containing validation status, detected format, breakdown, and any errors.

JavaScript (fetch)

const response = await fetch("/api/v1/validate", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ input: "DE89370400440532013000" }) });

const data = await response.json();

const isValid = data.result.isValid; // true

The response JSON includes the detected format, a detailed breakdown of the IBAN components, and the validation result.

Python (requests)

resp = requests.post("https://bankcheck.io/api/v1/validate", json={"input": "DE89370400440532013000"})

data = resp.json()

is_valid = data["result"]["isValid"] # True

The response structure is identical regardless of the client language.

Validation vs Verification

It is important to understand the distinction between validation and verification when working with bank details. These are two different operations with different guarantees.

AspectValidationVerification
What it checksFormat, length, checksum, country rulesAccount exists and is active at the bank
How it worksAlgorithmic (no network call needed)Requires querying the bank's systems
SpeedInstant (sub-millisecond)Seconds to days
GuaranteeNumber is structurally correctAccount is real and reachable

BankCheck performs validation. It checks that the bank number conforms to the correct format, passes the relevant checksum algorithm, and matches the expected structure for its country. It does not contact the bank to confirm the account exists. Validation catches the vast majority of user-entry errors (typos, transposed digits, wrong length) but cannot guarantee the payment will succeed.

IBAN MOD-97 in JavaScript

The IBAN checksum uses the MOD-97 algorithm defined in ISO 13616. Below is a pseudocode walkthrough of how it works. This is for educational purposes — for production use, call the BankCheck API or use a well-tested library. For a deeper explanation, see our guide on the IBAN validation algorithm.

Step 1: Rearrange the IBAN

Move the first 4 characters (country code + check digits) to the end of the string. For GB29NWBK60161331926819, this becomes NWBK60161331926819GB29.

Step 2: Convert letters to numbers

Replace each letter with its position in the alphabet plus 9. A becomes 10, B becomes 11, and so on up to Z which becomes 35. The rearranged string becomes a very large integer. For example, N = 23, W = 32, B = 11, K = 20, G = 16, B = 11.

Step 3: Compute MOD-97 using chunked arithmetic

The resulting number is too large for standard integer types. Instead, process it in chunks: take the first 9 digits, compute the remainder when divided by 97, prepend that remainder to the next chunk, and repeat until the entire number is processed.

In pseudocode:

remainder = 0

for each chunk of 7 digits from the numeric string:

remainder = (remainder + chunk) mod 97

Step 4: Check the result

If the final remainder is 1, the IBAN is valid. Any other result means the IBAN contains an error. This single check catches over 99.97% of transcription errors, including transposed digits and single-character substitutions.

ABA Routing Number Checksum

US routing numbers use a weighted checksum algorithm based on the digits' positions. The algorithm multiplies each of the 9 digits by a weight from the repeating pattern 3, 7, 1, then checks whether the sum is divisible by 10.

Given a routing number with digits d1 through d9, the formula is:

sum = 3*d1 + 7*d2 + 1*d3 + 3*d4 + 7*d5 + 1*d6 + 3*d7 + 7*d8 + 1*d9

If sum mod 10 === 0, the routing number passes the checksum. For example, routing number 021000021 (JPMorgan Chase):

3*0 + 7*2 + 1*1 + 3*0 + 7*0 + 1*0 + 3*0 + 7*2 + 1*1 = 0 + 14 + 1 + 0 + 0 + 0 + 0 + 14 + 1 = 30

30 mod 10 = 0, so the checksum passes. Like the IBAN MOD-97 algorithm, this check catches transposed and substituted digits but does not confirm the routing number is currently active at a bank.

Error Handling

Good validation is not just about returning true or false. The error messages you show users determine whether they can fix the problem themselves or need to contact support. Generic messages like “Invalid IBAN” are unhelpful. Specific messages like “IBAN is 2 characters too short for a German account” tell the user exactly what to fix.

The BankCheck API returns structured error information when validation fails. The response includes an error code, a human-readable message, and the detected format:

Example error response

{ "apiVersion": "1", "result": { "isValid": false, "format": "iban", "errors": [{ "code": "INVALID_LENGTH", "message": "German IBANs must be 22 characters, got 20" }] } }

When building your own validation layer, follow the same principle. Return the specific problem (wrong length, invalid checksum, unknown country code) along with enough context for the user to correct it. If the IBAN is too short, tell them by how many characters. If the country code is unrecognized, suggest they check the first two letters.

Testing Strategies

A robust validation implementation requires thorough testing across formats, countries, and edge cases. Here are the strategies that matter most:

  • Use known-valid example IBANs from each country. The IBAN registry published by SWIFT includes example IBANs for every participating country. Test your validator against these to ensure country-specific rules (length, BBAN structure, character sets) are handled correctly.
  • Test boundary cases. Check IBANs that are one character too short, one character too long, contain lowercase letters, include spaces, or have special characters. Verify that your validator normalizes input (strips spaces, uppercases letters) before checking.
  • Test known-invalid IBANs. Create IBANs with incorrect check digits, invalid country codes, and wrong-length BBANs. Confirm your validator returns the correct error for each case, not just a generic failure.
  • Test routing numbers with the checksum. Use real routing numbers from major US banks (publicly available) and verify both the 3-7-1 checksum and the Federal Reserve district prefix. Also test with numbers that have valid format but fail the checksum.
  • Test sort codes against known ranges. UK sort codes follow specific range allocations for each bank. Test with valid sort codes from major UK banks and with numbers outside any allocated range.
  • Test empty input and garbage input. Your validator should handle empty strings, null values, single characters, and strings of random symbols gracefully without throwing exceptions.

Frequently Asked Questions

Is the BankCheck API free?
Yes. The BankCheck validation API is free to use with no signup, no API key, and no rate limiting for reasonable usage. CORS is enabled for all origins, so you can call it directly from client-side JavaScript. The API supports IBANs, US routing numbers, UK sort codes, and SWIFT/BIC codes.
Can I validate sort codes via the API?
Yes. Send the sort code (with or without hyphens) to the same /api/v1/validate endpoint. The API auto-detects the format. You can also pass "format": "uk-sort-code" explicitly to skip auto-detection. The response includes the bank name, branch, and validation status.
Does validation guarantee a payment will succeed?
No. Validation confirms that the bank number is structurally correct: right length, valid checksum, recognized country code, and proper character format. It does not confirm the account exists, is active, or can receive payments. An IBAN can pass every validation check and still belong to a closed account. Validation catches typos and formatting errors, which account for the vast majority of payment failures, but it is not a guarantee of successful delivery.
How do I handle country-specific validation rules?
Each IBAN country has its own BBAN (Basic Bank Account Number) structure: different lengths, character sets (some allow letters, others are digits only), and internal formats. The BankCheck API handles all of this automatically. If you are implementing validation yourself, you need a per-country rule table specifying the expected IBAN length and BBAN pattern. The SWIFT IBAN Registry publishes this data. For routing numbers and sort codes, the rules are simpler (fixed length and digit-only), but you still need to check the checksum and validate the prefix ranges.

Try the API

The fastest way to get started is to make a single request and inspect the response. No signup required. Visit our API documentation for the complete reference, including response schemas for each format, error codes, and the full list of supported countries. You can also test validation interactively using our IBAN validator, routing number checker, or sort code lookup — each tool uses the same validation engine that powers the API.

Related Guides

IBAN Validation Algorithm Explained

8 min read

How to Verify Bank Details Before Sending Money

8 min read

Back to all guides.