Schwifty IBAN and BIC Validation

2026.3.0 · active · verified Sat Apr 11

Schwifty is a Python library for easily working with IBANs and BICs as specified by the ISO, enabling validation, parsing, and generation of international bank account numbers and business identifier codes. It is actively maintained with regular monthly or bi-monthly releases, and the current version is 2026.3.0.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize `IBAN` and `BIC` objects, access their components, and generate new IBANs. Validation happens automatically upon instantiation, raising a `ValueError` (or a more specific `SchwiftyException` subclass) for invalid inputs.

from schwifty import IBAN, BIC

# Validate and parse an IBAN
try:
    iban = IBAN('DE89 3704 0044 0532 0130 00')
    print(f"IBAN: {iban.formatted}")
    print(f"Country Code: {iban.country_code}")
    print(f"Bank Code: {iban.bank_code}")
    print(f"Account Code: {iban.account_code}")
    print(f"BIC (if available): {iban.bic}")
except ValueError as e:
    print(f"Invalid IBAN: {e}")

# Generate an IBAN
generated_iban = IBAN.generate('GB', bank_code='040004', account_code='34340004')
print(f"Generated IBAN: {generated_iban.formatted}")

# Create and validate a BIC
try:
    bic = BIC('COBADEFFXXX')
    print(f"BIC: {bic.formatted}")
    print(f"Country Code: {bic.country_code}")
except ValueError as e:
    print(f"Invalid BIC: {e}")

view raw JSON →