Credit card number format: length, IIN ranges and check digit by network
Every card number follows the same structure: a network prefix, an issuer, an account number and a Luhn check digit. Here is how long each network's numbers are, what they start with, and how the check digit works.
How many digits are in a credit card number?
Most cards have 16 digits: Visa, Mastercard, Discover, JCB and UnionPay. American Express uses 15, and Diners Club cards in the 36 range use 14. The international standard for card numbers, ISO/IEC 7812, allows up to 19 digits, and Maestro cards can be as short as 12. A checkout that only accepts exactly 16 digits turns away valid Amex, Diners Club and 19-digit cards.
The parts of a card number
- Major industry identifier (MII): the first digit. Under ISO/IEC 7812, 4 and 5 mean banking and financial, 3 means travel and entertainment, 6 means merchandising and banking.
- Issuer identification number (IIN or BIN): the first 6 or 8 digits, including the MII. It identifies the network and the issuing bank. Visa and Mastercard moved to 8-digit BINs in 2022. Look one up with the BIN lookup tool.
- Account identifier: the digits between the IIN and the last digit, assigned by the issuer.
- Check digit: the final digit, calculated with the Luhn algorithm so that typos can be caught before a payment is attempted.
Card number format by network
| Network | Starts with (IIN) | Length | Security code | Luhn |
|---|---|---|---|---|
| Visa | 4 | 13, 16, 19 | CVV2 (3) | Yes |
| Mastercard | 51 to 55, 2221 to 2720 | 16 | CVC2 (3) | Yes |
| American Express | 34, 37 | 15 | CID (4) | Yes |
| Discover | 6011, 644 to 649, 65, 622126 to 622925 | 16, 17, 18, 19 | CID (3) | Yes |
| JCB | 3528 to 3589 | 16, 17, 18, 19 | CAV2 (3) | Yes |
| Diners Club | 300 to 305, 3095, 36, 38 to 39 | 14, 15, 16, 17, 18, 19 | CVV (3) | Yes |
| UnionPay | 62, 8100 to 8171 | 16, 17, 18, 19 | CVN2 (3) | Mostly |
| Maestro | 5018, 5020, 5038, 5893, 6304, 6759, 6761 to 6763, Other 50 and 56 to 69 ranges | 12, 13, 14, 15, 16, 17, 18, 19 | CVC2 (3) | Yes |
| RuPay | 60, 65, 81, 82, 508, 353, 356 | 16 | CVV (3) | Yes |
| Mir | 2200 to 2204 | 16, 17, 18, 19 | CVP2 (3) | Yes |
| Troy | 9792, 65 (some ranges) | 16 | CVV (3) | Yes |
| Verve | 506099 to 506198, 507865 to 507964, 650002 to 650027 | 16, 18, 19 | CVV (3) | Yes |
| Hipercard | 606282 | 16 | CVC (3) | Yes |
Some prefixes are shared (for example 65 is used by Discover, RuPay and Troy co-branded cards), so the prefix alone does not always identify the network. Ranges are cross-checked against ISO/IEC 7812 references, network documentation and widely used open-source card detection tables.
What card starts with 2, 3, 4, 5, 6, 8 or 9?
| First digit | ISO/IEC 7812 category | Card networks |
|---|---|---|
| 2 | Airlines, financial and future assignments | |
| 3 | Travel and entertainment | |
| 4 | Banking and financial | |
| 5 | Banking and financial | |
| 6 | Merchandising and banking | |
| 8 | Healthcare, telecoms and future assignments | |
| 9 | Assigned by national standards bodies |
How the Luhn algorithm checks a card number
The Luhn algorithm (also called mod 10) is defined in ISO/IEC 7812 and used by almost every card network. It is a checksum, not encryption: it catches every single mistyped digit and most swaps of two neighbouring digits, but it says nothing about whether the account exists or has funds. Here it is step by step on Stripe's public Visa debit test number:
Number: 4000 0566 5566 5556 (16 digits)
- Start from the rightmost digit (the check digit) and move left.
- Double every second digit, starting with the one just left of the check digit.
- If doubling gives a number above 9, subtract 9 (same as adding its two digits).
- Add every value together. The number is valid if the total ends in 0.
| Digit | 4 | 0 | 0 | 0 | 0 | 5 | 6 | 6 | 5 | 5 | 6 | 6 | 5 | 5 | 5 | 6 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Double? | x2=8 | - | x2=0 | - | x2=0 | - | x2=12 | - | x2=10 | - | x2=12 | - | x2=10 | - | x2=10 | - |
| Value | 8 | 0 | 0 | 0 | 0 | 5 | 3 | 6 | 1 | 5 | 3 | 6 | 1 | 5 | 1 | 6 |
Total: 50. 50 mod 10 = 0, so the number passes the Luhn check.
Working backwards: without the check digit, the other digits add up to 44. The check digit is whatever brings that total to the next multiple of 10: (10 - 4) mod 10 = 6, which matches the last digit.
CVV meaning and security code names
CVV stands for Card Verification Value: the short code printed on the card that proves the buyer has the card in hand for online and phone payments. It is never part of the card number, and merchants are not allowed to store it after authorization. Each network has its own name for it:
| Network | Name | Stands for | Digits | Where |
|---|---|---|---|---|
| Visa | CVV2 | Card Verification Value 2 | 3 | Back |
| Mastercard, Maestro | CVC2 | Card Validation Code 2 | 3 | Back |
| American Express | CID | Card Identification Number | 4 | Front |
| Discover | CID | Card Identification Number | 3 | Back |
| JCB | CAV2 | Card Authentication Value 2 | 3 | Back |
| UnionPay | CVN2 | Card Verification Number 2 | 3 | Back |
| Mir | CVP2 | Card Verification Parameter 2 | 3 | Back |
Card expiry date format
The expiry date is printed as MM/YY, for example 08/29 for August 2029. The card stays valid through the last day of that month. The date is not encoded in the card number, so a number validator cannot tell you whether a card has expired; payment forms and APIs collect it separately as a month and a year.
Expired cards are one of the most common reasons subscription payments fail. When the issuer sends a new card, network card updater services can pass the new expiry date to the merchant, and a well-timed reminder covers the rest.
Card number format FAQ
How many digits are in a credit card number?
Most credit and debit card numbers are 16 digits (Visa, Mastercard, Discover, JCB, UnionPay). American Express uses 15 digits and many Diners Club cards use 14. The standard behind card numbers, ISO/IEC 7812, allows up to 19 digits, and Maestro cards can be as short as 12.
What card starts with 3, 4, 5 or 6?
A 4 is always Visa. A 5 is usually Mastercard (51 to 55) or Maestro. A 3 is American Express (34, 37), JCB (3528 to 3589) or Diners Club (300 to 305, 36, 38, 39). A 6 is usually Discover (6011, 644 to 649, 65) or UnionPay (62). A 2 is Mastercard (2221 to 2720) or Mir (2200 to 2204).
What is the Luhn algorithm?
The Luhn algorithm (mod 10) is the checksum used for the last digit of a card number. Starting from the right, double every second digit, subtract 9 from any result above 9, and add everything up. A valid number has a total that ends in 0. It catches every single mistyped digit and most swaps of two adjacent digits.
What does CVV mean?
CVV stands for Card Verification Value, the 3 or 4 digit security code printed on the card. Networks use different names for it: CVV2 (Visa), CVC2 (Mastercard), CID (American Express and Discover), CAV2 (JCB) and CVN2 (UnionPay). It is not part of the card number, so a number validator cannot check it.
What is the card expiry date format?
Cards print the expiry date as MM/YY, for example 08/29. The card is valid through the last day of that month. The expiry date is not encoded in the card number; payment forms and APIs collect it as a separate month and year.