[][src]Crate iban

This crate provides an easy way to validate an IBAN (International Bank Account Number). To do so, you can use the function parse(). This will check the IBAN rules as well as the BBAN structure. The provided Iban structure provides many methods to easy the handling of an IBAN. Many of these methods are provided via the IbanLike trait.

When BBAN parsing fails, the error type ParseIbanError provides useful information about what went wrong. Additionally, the error contains BaseIban, which can still be used to access useful information.


The following example does a full validation of the IBAN and BBAN format.

use iban::*;

let account = "DE44500105175407324931".parse::<Iban>()?;

assert_eq!(account.country_code(), "DE");
assert_eq!(account.check_digits(), 44);
assert_eq!(account.bban(), "500105175407324931");
assert_eq!(account.electronic_str(), "DE44500105175407324931");
assert_eq!(account.to_string(), "DE44 5001 0517 5407 3249 31");
assert_eq!(account.bank_identifier(), Some("50010517"));
assert_eq!(account.branch_identifier(), None);

What does this library provide?

  • A Iban type that can be used to parse account numbers very quickly. It doesn't require allocations at all, and instead leverages arrayvec under the hood.
  • A flexible API that is useful even when the country is not in the Swift registry (using BaseIban). Instead of using panic, the crate provides typed errors with what went wrong.
  • All functionality can be used in a no_std environment (except for the implementation of std traits).
  • Optional serialization and deserialization via serde.
  • CI tested results via the Swift provided and custom test cases, as well as proptest.
  • #![forbid(unsafe_code)], making sure all code is written in safe Rust.


The crate can be found on crates.io. To use this crate, just add it as an dependency:

iban_validate = "4"


The following features can be used to configure the crate:

  • std: Enabled by default. Enable the standard library. It is only used to provide implementations of Error.
  • serde: Enable serde support for Iban and BaseIban.



Represents an IBAN that passed basic checks, but not necessarily the BBAN validation. This corresponds to the validation as described in ISO 13616-1.


Represents an IBAN. To obtain it, make use of the parse() function, which will make sure the string follows the ISO 13616 standard. Apart from its own methods, Iban implements IbanLike, which provides more functionality.



Indicates that the string does not follow the basic IBAN rules.


An error indicating the IBAN could not be parsed.



A trait that provide basic functions on an IBAN. It is implemented by both Iban, which represents a fully validated IBAN, and BaseIban, which might not have a correct BBAN.