Every American bank transfer starts with nine digits: the ABA routing number. The first eight identify the bank. The ninth is a check digit, and it is computed with one of the oldest checksums still in daily use: multiply the digits by the repeating weights 3, 7, 1 and add them up. If the total is a multiple of 10, the number is well formed.
Take 021000021. The weights run 3, 7, 1, 3, 7, 1, 3, 7, 1 across the nine digits:
0x3 + 2x7 + 1x1 + 0x3 + 0x7 + 0x1 + 0x3 + 2x7 + 1x1
= 0 + 14 + 1 + 0 + 0 + 0 + 0 + 14 + 1
= 30
Thirty divides by ten, so it passes. Change the last digit to 2 and the total becomes 31, which fails. One wrong digit, one failed transfer, caught before the money moves.
It is not the Luhn algorithm. Luhn, the check behind every credit card number, doubles alternate digits and adds the digits of the products. The ABA rule never doubles anything; it just weights and sums. Both are mod-10 checks, but they are different checks, and a number that passes one will usually fail the other. Do not validate a routing number with Luhn.
Here is the whole validator in JavaScript:
function abaCheckDigit(firstEight) {
const weights = [3, 7, 1, 3, 7, 1, 3, 7];
const sum = [...firstEight].reduce(
(total, digit, i) => total + Number(digit) * weights[i], 0);
return String((10 - (sum % 10)) % 10);
}
function isValidRoutingNumber(nineDigits) {
if (!/^\d{9}$/.test(nineDigits)) return false;
return abaCheckDigit(nineDigits.slice(0, 8)) === nineDigits[8];
}
isValidRoutingNumber('021000021'); // true, sum 30
isValidRoutingNumber('091000019'); // true, sum 80
isValidRoutingNumber('123456780'); // true, sum 150
isValidRoutingNumber('021000022'); // false, sum 31
Three facts worth knowing before you trust a passing result.
First, the check catches every single-digit typo. Weights 3, 7, and 1 share no factor with 10, so changing any one digit always changes the total by something that is not a multiple of 10. It catches most adjacent transpositions too, but not all of them: swapping two digits whose values differ by 5 in a 3-weight and 7-weight position leaves the total unchanged.
Second, a pass is weak evidence. Exactly 1 in 10 random nine-digit strings passes a mod-10 check, by pure arithmetic. A passing number is correctly formed, not confirmed as a real bank. The first two digits add a little more signal: 01 to 12 are the twelve Federal Reserve districts (02 is New York, 06 is Atlanta), 21 to 32 are the old thrift series, 61 to 72 are electronic transactions, and 80 is traveller's cheques. Anything outside those ranges was never assigned under the published scheme.
Third, treat routing numbers as strings, never as numbers. 021000021 starts with a zero, and the moment you parse it as an integer you have an eight-digit number that fails every check. The same bug bites card numbers, phone numbers, and postcodes. If it has a leading zero and you never do arithmetic on it, it is a string.
I built a free validator that shows the full working, computes the check digit from eight digits, decodes the district prefix, and bulk-checks up to 100 numbers at once: ABA Routing Number Validator. Everything runs in your browser, and a pass still means correctly formed only, never confirmed as a real bank.
Top comments (0)