Advertiser Disclosure

Decoding Your Credit Card Number

Credit Cards
With so many websites offering free financial tools, it can be hard to know whom to trust. At NerdWallet, we spend literally 1,000s of hours researching partner offers and following strict editorial integrity to match you with the perfect choice. We even share how we make money so you can enjoy our expert advice and researched recommendations with total clarity and confidence.
Decoding Your Credit Card Number

Have you ever been up late at night, unable to sleep, wondering how you might one day decode all the digits on your credit card number? Perhaps it requires a World War II code-breaking device, you muse.

Well, it isn’t quite that complicated, but there are parallels. Everything involving decoding credit numbers goes back to computers, and computers are what banks and issuers are reliant upon. So, yes, you kind of do need a code-breaking device — and that’s what this article is.

Card numbers are not random. In fact, each number has a very specific purpose, the last digit of which is the most important. Each set of digits that form a credit card number are pumped out by a special algorithm known as the Luhn formula. This algorithm is set up so a given combination of numbers must be divisible by 10.

When you swipe your credit card, the number is sent to the processor, and those digits are verified to see if they conform to the Luhn algorithm. If they don’t, the card is invalid.

That last digit in the string of numbers is called the “check number,” which ties off the algorithm so it is divisible by 10.

So now we know about the last digit. What about all the others? Each card company has its own formula.


Visa’s cards always start with the number 4. The next five numbers represent the actual bank that the card is issued under. Digits seven through 13 represent the account number for the cardholder, which may be different from your actual account number. The 13th digit is the check number.

For cards with 16 digits, the account number is two digits longer.


This is essentially the same as the Visa formula, but there’s a quirk. All MasterCards begin with the number 5. The second digit — combined with either the third, fourth or fifth — tells you the bank the card is issued under. All other numbers up to the 15th digit represent the account number. The 16th is the check number.

American Express

All American Express cards begin with either 34 or 37. The third digit denotes the kind of American Express card you hold. The fourth digit tells what currency the card is issued in. The fifth through 11th digits are the account number, and the next three go deeper, providing the card number within that account. Once again, the final digit is the check number.

» MORE: How to read your credit card statement

Other cards

A few other notable rules. Diner’s Club and Carte Blanche also start with the number 3. Discover Card has been assigned the number 6 as its first digit.

Impress your friends

If you want to be the life of the party, you can show people whether or not a card is valid.

For cards with 16 digits, note the first number, and then multiply each alternating number after that by two. Next, you take any double-digit numbers and add them to form a single digit. (Take the number 7, and double it to 14. Add 1 and 4 together to get 5.) Now go back to the numbers you haven’t done anything with (which will also be alternating). Add them up. You should get a multiple of 10. If so, the card is valid.

If not, call the police. Your friend has a counterfeit card!

Man with credit card image via Shutterstock.