What are a bank branch and account?
The branch (agência) is the identification of the bank unit where the
account was opened. In Brazil, it is represented by a 4-digit number, usually followed
by a check digit (DV) — an extra number calculated from the preceding digits,
which allows typing errors to be detected.
The checking or savings account is the number that identifies the
customer's account within the branch. It also has a check digit, calculated in a similar
way. Some banks add an operation (or product) code that classifies the
type of account (e.g., checking account, savings account, student account).
What is the modulo-11 algorithm?
Modulo 11 is a checksum algorithm used by several Brazilian banks to
calculate the check digit of branches and accounts. The algorithm walks through the
digits from right to left, multiplying each one by an increasing weight (starting at 2).
The sum of these products is divided by 11, and the remainder of the division determines
the DV.
The calculation works as follows:
- Walk through the digits from right to left.
- Multiply each digit by an increasing weight, starting at 2 (2, 3, 4, …), cycling according to the bank's rule.
- Sum all the products.
- Calculate the remainder of the division by 11 (sum % 11).
- The DV is 11 minus the remainder. Special cases (remainder 0, resulting in DV 11, and remainder 1, resulting in DV 10) are handled specifically by each bank.
DV rules by bank (as implemented in this tool)
Each bank has its own variation of modulo 11. The rules below are the ones adopted in
this tool, based on publicly available third-party documentation. They may differ from
each institution's official internal rules (which are not publicly documented with
official test vectors).
-
Banco do Brasil: account with up to 8 digits + 1 DV; branch with 4
digits + 1 DV. Weights 2..9 (account) and 2..5 (branch) cycling from the right. DV = 11
− remainder; if DV = 10 → "X"; if DV = 11 → 0.
-
Bradesco: account with 7 digits + 1 DV; branch with 4 digits + 1 DV.
Weights 2..7 (account) and 2..5 (branch) cycling from the right. DV = 11 − remainder;
if DV = 11 → 0; if DV = 10 → "P".
-
Caixa Econômica Federal: account with 8 digits + 1 DV, calculated on
the concatenation of operation (3 digits) + account. Weights 2..9 cycling. DV = 11 −
remainder; if DV = 10 or 11 → 0. The branch uses 4 digits with no DV (most common
format; may vary by account type/agreement).
This is the least publicly standardized rule among those implemented.
Frequently Asked Questions (FAQ)
Is the generated data from real accounts?
No. The branches, operations and accounts generated by this tool are
completely fictitious. The numbers are generated randomly, and the DV
is calculated using the documented rule for each bank. They are useful only for software
testing, filling development forms and validating systems. Do not use this data in
transactions, registrations or real documents.
Is the generated DV identical to what a real bank would calculate?
Not necessarily. The check digit follows each bank's
publicly documented modulo-11 rule, based on third-party material. Each bank
may have internal variations, exception tables or product-specific rules that are not
publicly documented with official test vectors. This tool is suitable for software tests
that implement this same public rule, but may not be compatible with every production
banking system.
What is the "operation" at Caixa Econômica Federal?
Caixa uses a 3-digit code called "operation" (or "product") that identifies the type of
account. For example: 001 for an individual checking account,
013 for an individual savings account, 023 for Caixa Fácil.
This code is part of the account's DV calculation and must be entered correctly during
validation.
Why can the DV be "X" or "P"?
In modulo 11, when the result of the calculation would be 10, some banks cannot
represent that value with a single digit. Banco do Brasil adopts the letter
X (similar to how it's used for other Brazilian documents) and Bradesco
adopts the letter P in that situation. Other banks simply use 0 when the DV
would be 10 or 11.
Can I use this data in bank homologation/sandbox systems?
It depends on the system. If the bank's homologation system validates the DV using the
same public modulo-11 rule documented here, it probably will. But many banking systems
perform additional checks (account existence, valid branch range, operation type), so
the result may vary. This tool does not replace official sandbox environments provided
by the banks.