Skip to main content

US Bank Routing Number Validation

You are probably here because you want to validate routing and bank account numbers. There is good and bad news.

Good news

US bank routing numbers follow a very strict format. That makes it so you can easily validate it and be assured that before you send that data to the back-end it passes the format requirements.

Bad News

Bank account numbers are not so fortunate. There is no strict format unlike IBAN. Dang it! I discuss is more here.

Routing Number

You can get really fancy and do some really deep validation for the routing number. As you can see here there is a lot behind the format including what each set of digits represents (what kind of institution is the bank, what Federal Reserve district it is in, which state its in, etc).

But we are going to keep it simple. There is a checksum. Thanks to BrainJar for presenting a simple solution.

First off the number is always 9 digits.

Next is the checksum algorithm.

Here is our example routing number:

Multiply the first digit by 3, the second by 7, the third by 1, the fourth by 3, the fifth by 7, the sixth by 1, the seventh by 3, the eight by 7 and the ninth by 1. Then add it all together, like so:

(3 x 3) + (2 x 7) + (4 x 1) +
(3 x 3) + (7 x 7) + (7 x 1) +
(5 x 3) + (1 x 7) + (6 x 1) = 120

If the total is an exact multiple of 10 (no remainder) then it passes the checksum and is valid.

120 % 10 == 0

Here is my javascript method:
function validateABA(n) {
   n = n ? n.match(/\d/g).join('') : 0;//get just digits
   var c = 0, isValid = false;

   if (n && n.length == 9){//don't waste energy totalling if its not 9 digits
  for (var i = 0; i < n.length; i += 3) {//total the sums
     c += parseInt(n.charAt(i), 10) * 3 +  parseInt(n.charAt(i + 1), 10) * 7 +  parseInt(n.charAt(i + 2), 10);
  isValid = c != 0 && c % 10 == 0;//check if multiple of 10

   return {//return an object telling whether its valid and if not, why.
  isValid: isValid,
  errorMsg: n.length != 9 ? 'Rounting number must be 9 digits' : (!isValid ? 'Invalid bank routing number.' : '')//determine the error message

Bank Account Number

Since there is no format for bank account numbers there isn't a ton you can do except for cover the basics. This leaves people having to speculate, so we will cover the best we can by understanding the speculations.

Account numbers range from 4-17 characters, but some claim they have seen as little as 2. You can most likely safely assume that its only going to be numbers, but nothing strictly says that there won't be letters. You could force numbers only until the first person complains, or just leave it up to the payment gateway at that point since we are only trying to give the best data we can to the back-end.

So what I did was just require it to be at least 2 characters and no longer than 17.

There you have it. With that you should be able to filter enough to get valid routing and account numbers for the US.


  1. Thanks for presenting a simple solution.

  2. I once had a moment when I urgently needed fairwinds routing number, but I could not find it in the documents and I had absolutely no time to call the bank to find out. I think it was one of my most brilliant ideas to start searching for information on the Intnet. I found a great site where you can find a number by the name of a bank and a bank by number. And don't have to multiply anything!

  3. Your website is really cool and this is a great inspiring article. Phonepe customer care

  4. Bank routing is used to connote which money related organization a check starts from. This can be significant on a number of levels and can be checked on the web. us bank routing number

  5. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. test bank

  6. Nice, but the JavaScript should also check to see if the first two digits are between 01 and 12.

  7. i am always looking for some free stuffs over the internet. there are also some companies which gives free samples. 먹튀검증

  8. Nice to be visiting your blog once more, it has been months for me. Well this article that ive been waited for therefore long. i want this article to finish my assignment within the faculty, and it has same topic together with your article. Thanks, nice share. 먹튀검증

  9. Pretty good post. I have just stumbled upon your blog and enjoyed reading your blog posts very much. I am looking for new posts to get more precious info. Big thanks for the useful info. here


Post a Comment

Popular posts from this blog

Quick Ratios with JavaScript

I always find myself needing to know how numbers compare. But I hate taking out a calculator or grabbing pencil and paper to work it out. So I wrote a small script to do it for me. Method Math.Ratio = function (rt1, rt2) { var rt1n = rt1.split(':'); var rt2n = rt2.split(':'); var rntd1i = false, rntd2i = false; for (var i = 0; i < rt1n.length; i++) { if (rt1n[i] == '?') { rntd1i = i; } } for (var ii = 0; ii < rt2n.length; ii++) { if (rt2n[ii] == '?') { rntd2i = ii; } } function rtDetermine(r1, r2, ri) { var isum = r1[0] / r1[1]; return ri == 0 ? r2[1] * isum : r2[0] / isum; } if (rntd1i !== false && rntd2i !== false) { console.warn('Whoops, can only work with one unknown number.'); return false; } else if (rntd1i !== false) { return rtDetermine(rt2n, rt1n, rntd1i); } else if (rntd2i !== false) { return rtDetermine(rt1n, rt2n, rntd2i); } else { console.warn('Whoops, need at le