sodcalculator

10 Tech How-To

How Credit Card Numbers Work: Structure Explained

Guide 10-31834 · Updated · Step by step

Credit card numbers look like random digits, but they follow a strict international standard (ISO/IEC 7812) that encodes the issuer, the account, and a built-in error check. This guide breaks down each part of the number, explains how the Luhn algorithm catches typos, and shows you how to read any card number you see. You don’t need anything special—just a card (or a photo of one) and a few minutes.

What You’ll Need

  • A credit, debit, or prepaid card to examine (optional but helpful).
  • A calculator or pen and paper to verify the Luhn check digit.

Step-by-Step

  1. Identify the card network from the first digit. The first digit is the Major Industry Identifier (MII). It tells you the category: 1 and 2 are airlines, 3 is travel/entertainment (e.g., American Express), 4 and 5 are banking/financial (Visa and Mastercard), 6 is merchandising/banking (Discover), 7 is petroleum, 8 is healthcare/telecom, 9 is national assignment. For most consumer cards, you’ll see 3, 4, 5, or 6.
  2. Find the Issuer Identification Number (IIN). The first six digits (including the MII) form the IIN, also called the Bank Identification Number (BIN). This identifies the bank or institution that issued the card. For example, 4xxxxx is a Visa, 51xxxx–55xxxx is a Mastercard, 34xxxx or 37xxxx is American Express, and 6011xx or 65xxxx is Discover. You can look up a BIN online to see the issuing bank, but the first six digits alone are enough to identify the network.
  3. Count the remaining digits to find the account number. The digits between the IIN and the last digit are your individual account number. For a 16-digit card (Visa, Mastercard, Discover), that’s digits 7 through 15 (9 digits). For a 15-digit American Express card, it’s digits 7 through 14 (8 digits). This number is unique to your account within that issuer.
  4. Note the final digit: the check digit. The last digit is not part of your account number—it’s a checksum calculated from all the preceding digits using the Luhn algorithm (also called mod 10). Its purpose is to catch accidental errors like a mistyped digit or a transposition (e.g., 12 vs 21).
  5. Verify the Luhn check digit (optional but illuminating). Starting from the rightmost digit (the check digit itself) and moving left, double every second digit. If doubling gives a two-digit number, add those digits together (e.g., 8 × 2 = 16 → 1 + 6 = 7). Now sum all the digits, including the check digit. The total must be a multiple of 10. If it isn’t, the number is invalid.
  6. Understand the total length. Most cards are 16 digits, but American Express uses 15, and some older or regional cards may use 13–19 digits. The length is not random; it’s part of the ISO standard and helps systems validate the number format.

Common Mistakes

  • Confusing the IIN with the account number. The first six digits are always the issuer identifier, not part of your personal account. Your account number starts at digit 7.
  • Thinking the check digit is part of your account. It’s a security feature, not a digit you need to remember. When you enter your card number online, the system recalculates the check digit to catch typos.
  • Assuming all cards have 16 digits. American Express is 15, and some prepaid or store cards may have 13–19. The length depends on the issuer and the network’s rules.
  • Misapplying the Luhn algorithm. Remember to start doubling from the rightmost digit (the check digit itself is not doubled). If you start from the left, you’ll get a wrong result.
  • Thinking the Luhn check is a security feature. It only catches accidental errors, not fraud. It doesn’t verify that the card is legitimate or has funds—just that the number is well-formed.

Tips

  • When testing a card number in a form, the Luhn check is often the first validation. If you get an error like “invalid card number,” it’s usually because of a typo, not because the card is declined.
  • You can identify the network quickly by the first digit: 4 = Visa, 5 = Mastercard, 3 = American Express (also 34/37), 6 = Discover (also 6011, 65).
  • If you’re building a payment form, never store the full card number. Use the first six and last four digits for display, and rely on the Luhn check for immediate feedback.
  • For curiosity, you can generate valid test numbers (like 4111 1111 1111 1111) that pass the Luhn check, but they won’t actually charge anything.

Troubleshooting

  • My card number is rejected as invalid, but I typed it correctly. Check for a missing digit or an extra space. Also, if the card is expired or reported lost, the issuer may block it, but that’s a different error than “invalid number.”
  • The Luhn check fails when I compute it manually. Re-read step 5: you must double every second digit starting from the rightmost digit (the check digit itself) and moving left. If you double the check digit, you’ll get a wrong sum. Also, when doubling gives a two-digit number, add the digits (e.g., 9×2=18 → 1+8=9).
  • I see a card with 19 digits—is that valid? Yes, some issuers (like certain prepaid or corporate cards) use up to 19 digits. The Luhn check still applies. The structure remains the same: IIN + account + check digit.
  • Why does my card number start with 3, but it’s not American Express? The MII 3 covers travel and entertainment cards, but some other card types (like certain Diners Club) also use 3. The first six digits will tell you the exact network.

Frequently Asked Questions

Q: Can I tell if a credit card is valid just by looking at the number?
A: You can tell if it’s well-formed by checking the Luhn algorithm and the length, but that doesn’t mean the card is active or has funds. It only confirms the number is syntactically correct.

Q: Do credit card numbers contain any personal information like my birthdate?
A: No. The number is purely a structured identifier. Your personal data is stored on the issuer’s systems, not encoded in the number itself.

Q: Why do some cards have 15 digits and others 16?
A: The length is determined by the network and issuer. American Express uses 15 digits, while Visa, Mastercard, and Discover typically use 16. Some regional networks use 13 or 19.

Q: What is the Luhn algorithm used for besides credit cards?
A: It’s also used for other identification numbers like Social Insurance Numbers (Canada), IMEI numbers for phones, and some national ID numbers. It’s a general error-detection method.

Q: Can I use the Luhn check to create a fake card number that works?
A: It will pass the format check, but real authorization requires the issuer’s system, which will reject it. It’s not a security bypass, just a data integrity check.

Q: Is the check digit always the last digit?
A: Yes, for credit cards following the ISO/IEC 7812 standard, the last digit is the Luhn check digit. It’s calculated from all preceding digits.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →