How a routing number is built
An ABA routing transit number (RTN) identifies a US financial institution in cheque clearing, ACH direct deposits and debits, and Fedwire transfers. It was introduced by the American Bankers Association in 1910 and always has nine digits:
| Digits | Name | Meaning |
|---|---|---|
| 1–2 | Prefix | Federal Reserve district (01–12), or the same district + 20 for thrift institutions (21–32), + 60 for electronic transaction identifiers (61–72), 00 for the US Government and 80 for traveler’s cheques |
| 3 | Processing center | The Federal Reserve check processing center originally assigned to the institution |
| 4 | State or city | 0 = located in the Federal Reserve city itself; 1–9 = the state within the district |
| 5–8 | Institution identifier | The institution’s number within its district |
| 9 | Check digit | Makes the weighted checksum a multiple of 10 |
Digits 1–4 together are the Federal Reserve routing symbol. On a cheque, the routing number is the first group of magnetic-ink (MICR) characters on the bottom left, between two ⑆ transit symbols; the account number and cheque number follow it.
The 3-7-1 checksum
The check digit protects against typing mistakes. Multiply the nine digits by the repeating weights 3, 7, 1, add the products, and the total must be divisible by 10:
3 × (d1 + d4 + d7) + 7 × (d2 + d5 + d8) + 1 × (d3 + d6 + d9) ≡ 0 (mod 10)
Worked example with 011000015: the products are 0, 7, 1, 0, 0, 0, 0, 7, 5. Their sum is 20, a multiple of 10, so the checksum is valid. To calculate a missing check digit, compute the weighted sum of the first eight digits and take (10 − sum mod 10) mod 10; type eight digits above to let the validator do it.
The weights catch every single-digit error and most swaps of two adjacent digits. They can’t catch everything: swapping two digits three positions apart, which share a weight, goes unnoticed, and so does any change that happens to keep the sum the same.
Validating routing numbers in code
- Strip spaces and dashes, then require exactly nine digits (
^\d{9}$). Keep the value as a string — leading zeros are significant, and storing it as an integer turns011000015into11000015. - Check the prefix against the valid ranges 00–12, 21–32, 61–72 and 80.
- Check the 3-7-1 checksum.
- For real payments, confirm that the number is in use with your payment provider or with the Federal Reserve’s E-Payments Routing Directory. Many ACH providers reject numbers that are not in the directory even though they pass the checksum.
In JavaScript the checksum is one line: [3,7,1,3,7,1,3,7,1].reduce((s, w, i) => s + w * rtn[i], 0) % 10 === 0.
Routing numbers for testing
For automated tests against a payment provider, use the provider’s documented test values: Stripe, for example, documents routing number 110000000 with test account numbers such as 000123456789 (successful payment) and 000222222227 (insufficient funds) — see Stripe’s ACH Direct Debit documentation. For testing your own form validation, any number that passes the prefix and checksum checks behaves like a real one. Don’t put generated or published routing numbers into live payment files: a valid-looking number can belong to a real institution.
Routing number vs SWIFT code vs account number
The routing number identifies the bank for domestic US transfers. International transfers to a US bank use the bank’s SWIFT code (BIC) instead — check its format with the SWIFT code checker — and the account number identifies your account within the bank. The US does not use IBANs. Some banks publish different routing numbers for ACH and for wire transfers, and large banks use different numbers by state, so always take the routing number from the account holder’s statement or online banking.
Frequently asked questions
Does a valid routing number mean the bank exists?
No. About one random 9-digit number in ten passes the checksum, and the prefix rule removes some more. Whether a routing number is assigned is recorded in the Federal Reserve’s E-Payments Routing Directory and by the ABA’s registrar.
Which routing number can I use for testing?
Use your payment provider’s documented test value. Stripe, for example, documents routing number 110000000 with account 000123456789 for a successful ACH test payment. For form-validation tests, any number that passes the checksum works.
Why does my routing number fail?
Usually a typo or a swapped pair of digits, which the checksum catches. Also check that you did not paste the account number or the check number, which are printed next to the routing number on a cheque.
Are ACH and wire routing numbers different?
Some banks publish a separate routing number for wire transfers. Both use the same format and checksum, so this validator checks either one.