IBAN
Brazilian IBANs (International Bank Account Number, country code BR): validation, formatting, parsing and decoding.
Validate
- JavaScript library
- Python library
- Go library7 cases fail
- Ruby library3 cases fail
- Rust library5 cases fail
- .NET library5 cases fail
- Erlang library
Validates a Brazilian IBAN. Any other country is invalid.
- Layout, 29 characters:
BR, 2 check digits (ISO 7064 MOD 97-10), 8-character ISPB (digits or letters), 5-digit branch, 10-digit account, 1-letter account type (usuallyCorP), 1 owner indicator (1to9, thenAtoZ). - Accepts the compact form or groups of 4 split by whitespace,
.,-or/, in any case, with optional whitespace around the value. The separator is optional at each group boundary, soBR15 000000000000 1093 2840 814P 2is also valid. The separators are the interchangeable mask characters of the CPF and CNPJ, alone or in a run (ISO 13616 prints one space), soBR1500000000000010932840814P-2andBR15 0000 0000 0000 1093 2840 814P 2are the same IBAN. Until 2.4.0 a run of separators between two groups made the IBAN invalid. - A separator away from a group boundary, or any character outside letters, digits and those separators, makes the IBAN invalid (
BR15 000 00000 0000 1093 2840 814P 2). The character is not stripped. A value that is not a string is invalid. - The layout is set by Resolução BCB 585/2026, art. 2º, which revoked Circular BCB 3.625/2013 and kept its layout. Art. 2º, III, makes the ISPB "oito caracteres alfanuméricos", so a letter in the ISPB is accepted, in any case. 2.4.0 accepted only digits there. Every other digit position still rejects a letter.
- The account type follows the ISO 13616 registry pattern (a letter). Art. 2º, VI, calls it "um caractere alfanumérico"; the registry form is kept, so a digit there is rejected.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | boolean |
Check if a Brazilian IBAN (International Bank Account Number) is valid. Only Brazilian IBANs (country code BR) are recognized; any other country returns false.
- Layout, 29 characters (Resolução BCB 585/2026, art. 2º, which revoked Circular BCB 3.625/2013 and kept its layout):
BR, 2 check digits (ISO 7064 MOD 97-10), 8 character ISPB, 5 digit branch, 10 digit account, 1 letter account type, 1 owner indicator. - The ISPB may hold letters: the Resolução makes it "oito caracteres alfanuméricos", where the Circular said "numéricos". Up to 2.4.0 only digits were accepted.
- Account type: any letter, usually
CorP. Owner:1to9, thenAtoZ. - Accepts the compact form or groups of 4 split by one whitespace,
.,-or/, in any case.
import { isValidIban } from '@brazilian-utils/brazilian-utils';
isValidIban('BR1500000000000010932840814P2'); // true
isValidIban('BR15 0000 0000 0000 1093 2840 814P 2'); // true (grouping spaces)
isValidIban('BR15-0000-0000-0000-1093-2840-814P-2'); // true (any of the mask characters)
isValidIban('BR1012AB34CD000010932840814P2'); // true (alphanumeric ISPB)
isValidIban('BR1500000000000010932840814P3'); // false (bad check digits)
isValidIban('BR15 000 00000 0000 1093 2840 814P 2'); // false (a separator inside a group)
isValidIban('DE89370400440532013000'); // false (non Brazilian IBAN)Source: Diretrizes de Implementação do IBAN no Brasil, Resolução BCB nº 585/2026, which revoked Circular BCB nº 3.625/2013, ISO 13616-1:2020.
Code: brazilian-utils/javascriptTry it with JavaScript isValidIban
Shared test cases (38) and the result in each library iban.isValid
Format
Formats an IBAN in the ISO 13616 print grouping: blocks of 4 characters separated by spaces, upper-cased. It does not validate the IBAN (use iban.isValid).
Statements and bank forms show the IBAN in this form.
- The function reads only letters and digits. The result is capped at the 29 characters of a Brazilian IBAN.
- Every other character (a hyphen, a dot, extra whitespace) is dropped, so
BR15 0000-0000.0000/1093 2840 814P-2gives the same result as the compact form. A value that is not a string gives an empty string. - A partial value is grouped as far as it goes (
BR15givesBR15), so the function works as an input mask. The check digits and the layout are not checked, and an IBAN of another country is grouped the same way.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | string |
Format an IBAN in the ISO 13616 print grouping: blocks of 4 characters, the presentation used on statements and bank forms. Does not validate; use isValidIban for that.
- Caps the result at 29 characters, the length of a Brazilian IBAN.
import { formatIban } from '@brazilian-utils/brazilian-utils';
formatIban('BR1500000000000010932840814P2'); // 'BR15 0000 0000 0000 1093 2840 814P 2'
formatIban('br1500000000000010932840814p2'); // 'BR15 0000 0000 0000 1093 2840 814P 2'
formatIban('BR15'); // 'BR15'
formatIban('BR15 0000-0000.0000/1093 2840 814P-2'); // 'BR15 0000 0000 0000 1093 2840 814P 2' (only letters and digits are read)Source: Diretrizes de Implementação do IBAN no Brasil, Resolução BCB nº 585/2026, which revoked Circular BCB nº 3.625/2013, ISO 13616-1:2020.
Code: brazilian-utils/javascriptTry it with JavaScript formatIban
Shared test cases (17) and the result in each library iban.format
Parse
- JavaScript library
- Python library
- Go library
- Ruby library2 cases fail
- Rust library
- .NET library
- Erlang library
Removes IBAN formatting and keeps letters and digits upper-cased, capped at 29 characters.
- A number is read only when it is a safe non-negative integer. A negative, fractional, non-finite or unsafe number gives an empty string (2.4.0 read the characters of any number, sign and decimal point dropped).
- Every character that is not a letter or a digit is dropped and the letters are upper-cased.
- A string is read as it is, so a value with no letter or digit, and a value that is neither a string nor a number, give an empty string.
| Parameter | Type | Required |
|---|---|---|
value | string | number | yes |
| returns | string |
Remove IBAN formatting, keep the letters and digits, uppercase the result, and cap it to the 29 characters of a Brazilian IBAN.
import { parseIban } from '@brazilian-utils/brazilian-utils';
parseIban('BR15 0000 0000 0000 1093 2840 814P 2'); // 'BR1500000000000010932840814P2'
parseIban('br15-0000.0000/0000 1093 2840 814p-2'); // 'BR1500000000000010932840814P2'Source: Diretrizes de Implementação do IBAN no Brasil, Resolução BCB nº 585/2026, which revoked Circular BCB nº 3.625/2013, ISO 13616-1:2020.
Code: brazilian-utils/javascriptTry it with JavaScript parseIban
Shared test cases (9) and the result in each library iban.parse
Decode
- JavaScript library
- Python library
- Go library3 cases fail
- Ruby library1 case fails
- Rust library
- .NET library1 case fails
- Erlang library
Parses a Brazilian IBAN into its fields. Returns null whenever iban.isValid would return false.
- Fields, all strings:
countryCode(alwaysBR),checkDigits(2 digits),bankIspb(8 characters, uppercase letters allowed since Resolução BCB 585/2026),branch(5 digits),account(10 digits),accountType(1 letter, usuallyCorP) andowner(1to9, thenAtoZ). Letters come upper-cased and the zero padding is kept. - The input rules are those of
iban.isValid: the compact or grouped form, a run of mask characters between groups, any case. A value that is not a string givesnull.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | IbanInfo | null |
Parse a Brazilian IBAN into its fields. Returns an IbanInfo object, or null whenever isValidIban would return false.
- Fields, all strings:
countryCode,checkDigits,bankIspb,branch,account,accountType(usuallyCorP) andowner(1to9, thenAtoZ). - Same input rules as
isValidIban.
import { getIbanInfo } from '@brazilian-utils/brazilian-utils';
getIbanInfo('BR1500000000000010932840814P2');
// {
// countryCode: 'BR',
// checkDigits: '15',
// bankIspb: '00000000',
// branch: '00001',
// account: '0932840814',
// accountType: 'P',
// owner: '2'
// }
getIbanInfo('DE89370400440532013000'); // null (non Brazilian IBAN)
getIbanInfo('BR15 000 00000 0000 1093 2840 814P 2'); // null (a separator inside a group)Source: Diretrizes de Implementação do IBAN no Brasil, Resolução BCB nº 585/2026, which revoked Circular BCB nº 3.625/2013, ISO 13616-1:2020.
Code: brazilian-utils/javascriptTry it with JavaScript getIbanInfo
Shared test cases (22) and the result in each library iban.getInfo
Official sources
- bcb.gov.br/estabilidadefinanceira/exibenormativo
- bcb.gov.br/pre/normativos/…/circ_3625_v1_O.pdf
- bcb.gov.br/content/estabilidadefinanceira/…/IBAN-Guidelines_ port.pdf
- iso.org/standard/81090.html
- iso.org/standard/31531.html
See also Banks
Last updated on
