This is Flash Payments' fork of IBANTools by Saša Jovanić. IBANTools is an excellent, carefully maintained library, and almost all of the work here is his and its contributors'. Thank you!
The IBAN registry changes happen monthly, but the original project gets less than annual updates. This fork will be maintained on a monthly basis.
The API is the same.
- Removed the dependency on Ruby.
- Fixed a bug, which restored support for a dozen countries.
- Updated the country data to the current (2026) SWIFT IBAN registry, correcting bank codes, account numbers and formats in 56 countries.
IBANTools is TypeScript/JavaScript library for validation, creation and extraction of IBAN, BBAN and BIC/SWIFT numbers.
For more information about IBAN/BBAN see wikipedia page and IBAN registry.
For more information about BIC/SWIFT see this wikipedia page.
$ npm install ibantools-minimal
To keep require('ibantools') in your code unchanged, install it under the original name with an npm alias:
$ npm install ibantools@npm:ibantools-minimal
The API is the same as IBANTools; see its full documentation with examples.
const ibantools = require('ibantools-minimal');
const iban = ibantools.electronicFormatIBAN('NL91 ABNA 0417 1643 00'); // 'NL91ABNA0417164300'
ibantools.isValidIBAN(iban);
// If you want to know reason why IBAN is invalid
ibantools.validateIBAN('NL91ABNA0517164300');
// Returns { valid: false, errorCodes: [ibantools.ValidationErrorsIBAN.WrongIBANChecksum] }
// Validate BIC
ibantools.isValidBIC('ABNANL2A');import { isValidIBAN, extractIBAN } from 'ibantools-minimal';The package bundles type definitions, so tsc picks them up automatically.
Country specifications can be extended with national BBAN validations by calling setCountryBBANValidation.
For example, to fully syntactically check German IBAN, you can install IBANTools-Germany and add this with
const ibantools = require('ibantools-minimal');
const ibantoolsGermany = require("ibantools-germany");
ibantools.setCountryBBANValidation("DE", ibantoolsGermany.isValidBBAN);
script/registry.txt is a copy of the SWIFT IBAN registry, and script/iban_spec.js is built from it. The library
itself, src/ibantools.ts, is updated from it in place rather than regenerated, because it also holds national checks,
countries the registry lacks and fixes to registry values.
- In a browser, download the registry as text from the SWIFT IBAN page. SWIFT blocks scripted downloads, so this step is manual.
- Save it as
registry.txtin thescriptfolder, replacing the old one, and runnpm run update-registry. It refuses a file that isn't the registry or is cut off, lists the countries added, removed or changed since the last commit, and rebuildsscript/iban_spec.js. - Run
npm run update-srcto carry the registry intosrc/ibantools.ts(add-- --dry-runto only see the report). It adds whatsrc/ibantools.tslacks, such as a missing bank position, and reports every value that differs from the registry. It changes a differing value only when run with-- --overwrite, and never one marked as a fix. It also lists the values the registry lacks, which it never removes, and the registry countries that have no entry insrc/ibantools.ts. - Review
git diff, decide on each reported difference, and add tests for what changed.
A value fixed by hand carries a comment on the line above it, starting with // Not from the IBAN registry:, saying
why and where it was fixed:
// Not from the IBAN registry: its 5-digit bank code is a 2-digit bank and a 3-digit branch code (be43ebb).
bank_identifier: '0-1',npm run update-src never changes a marked value, and tells you when the registry agrees with it again so the comment
can go. Mark any value you fix by hand the same way.
npm run build-spec rebuilds script/iban_spec.js from the current registry without replacing it.
Please send fixes to the original project first, following its contribution guide. Report problems specific to this fork in our issues.
This work is licensed under the MIT license (see LICENSE).
SPDX-License-Identifier: MIT