Advertisement

Credit Card Number Format

What each digit of a card number means, the prefixes, lengths and spacing for every major brand (including JCB, UnionPay and Maestro), and how expiry dates and security codes are formatted.

Advertisement
MII (1st digit) IIN / BIN (first 6–8 digits) Account identifier Check digit (Luhn)

Example: the test number 4111 1111 1111 1111. Check any number with the card validator, or create test numbers in any format with the generator.

Advertisement

The four parts of a card number

A payment card number — officially the primary account number or PAN — is defined by the international standard ISO/IEC 7812. It is between 8 and 19 digits long, although almost every card in use has 15, 16 or 19 digits. Every PAN is made of four parts:

  1. Major Industry Identifier (MII) — the first digit. It names the industry of the issuer: 4 and 5 are banking and finance, 3 is travel and entertainment, 6 is merchandising and banking.
  2. Issuer Identification Number (IIN) — the first six or eight digits, also called the BIN (bank identification number). It identifies the card network and the bank that issued the card, and often the card type (credit, debit, prepaid), level and country. Since 2022 the standard uses 8-digit IINs, so systems should no longer assume 6.
  3. Account identifier — the digits between the IIN and the last digit, chosen by the issuer for the individual card. It is not your bank account number.
  4. Check digit — the last digit, calculated from all the others with the Luhn algorithm. It lets a form catch typos before the payment is sent.

Card number format by brand

The prefix (IIN range) tells you the brand, and the brand tells you the allowed lengths, the usual grouping and the type of security code:

BrandStarts withLengthGroupingSecurity code
Visa413, 16, 194-4-4-4CVV2 · 3 digits, back
Mastercard51–55, 2221–2720164-4-4-4CVC2 · 3 digits, back
American Express34, 37154-6-5CID · 4 digits, front
Discover6011, 644–649, 6516–194-4-4-4CID · 3 digits, back
JCB3528–358916–194-4-4-4CAV2 · 3 digits, back
Diners Club300–305, 36, 38–3914–194-6-4 (14 digits)3 digits, back
UnionPay6216–194-4-4-4CVN2 · 3 digits, back
Maestro5018, 5020, 5038, 5893, 6304, 6759, 6761–676312–19varies (4-4-4-4 for 16)3 digits, back (optional on some)

Other domestic schemes follow the same rules with their own prefixes, for example Mir in Russia (2200–2204) and RuPay in India (mostly 60, 65, 81, 82 and 508). Ranges overlap in places: 622126–622925 is both UnionPay and Discover, and some Maestro ranges sit inside the 5 and 6 ranges. Check the more specific prefix first.

Advertisement

JCB credit card number format

JCB numbers start with 3528 to 3589 and have 16 digits, grouped 4-4-4-4 like 3530 1113 3330 0000 (a Braintree test number). The scheme allows up to 19 digits. The last digit is a Luhn check digit and the three-digit security code, called CAV2, is on the back. Because JCB numbers begin with 35, a validator that treats every number starting with 3 as American Express (15 digits, 4-digit code) rejects them — one of the most common card validation bugs. In the US, JCB cards are processed on the Discover network.

Validation patterns (regex)

These regular expressions check the prefix and length of a number with spaces and dashes removed. Use them together with the Luhn check:

BrandPattern
Visa^4[0-9]{12}(?:[0-9]{3}){0,2}$
Mastercard^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$
American Express^3[47][0-9]{13}$
Discover^(?:6011|64[4-9][0-9]|65[0-9]{2})[0-9]{12,15}$
JCB^35(?:2[89]|[3-8][0-9])[0-9]{12,15}$
Diners Club^3(?:0[0-5]|[689][0-9])[0-9]{11,16}$
UnionPay^62[0-9]{14,17}$
Maestro^(?:5018|5020|5038|5893|6304|6759|676[1-3])[0-9]{8,15}$

Spacing and display rules

Expiry date format

The expiry date is printed as MM/YY, for example 08/29. The card is valid until the last day of that month. Payment APIs usually take the month and a four-digit year as separate fields, so your form should convert 08/29 to month 8 and year 2029. Reject months outside 01–12 and dates in the past, and allow dates up to about 20 years ahead.

CVV, CVC and CID formats

The card security code has a different name for each brand but the same purpose: proving that the person paying has the physical card. It is not derived from the card number by any public formula.

PCI DSS forbids merchants from storing the security code after authorization, even encrypted. In test data, a random code of the right length is all you need.

Major Industry Identifier values

First digitIndustry
0ISO/TC 68 and other industry assignments
1Airlines
2Airlines, financial and future industry assignments (Mastercard 2-series)
3Travel and entertainment (American Express, Diners Club, JCB)
4Banking and financial (Visa)
5Banking and financial (Mastercard, Maestro)
6Merchandising and banking (Discover, UnionPay, Maestro)
7Petroleum and other future industry assignments
8Healthcare, telecommunications and other future industry assignments
9Assignment by national standards bodies

Frequently asked questions

How many digits does a credit card number have?

Usually 16. American Express uses 15, most Diners Club cards 14, and Visa, Discover, JCB, UnionPay and Maestro allow up to 19. The international standard allows 8 to 19 digits.

What is the format of a JCB card number?

16 digits starting with 3528 to 3589, shown in four groups of four (for example 3530 1113 3330 0000). JCB allows up to 19 digits. The last digit is a Luhn check digit, and the 3-digit CAV2 code is on the back.

What do the first digits of a card number mean?

The first digit is the Major Industry Identifier. The first six to eight digits are the Issuer Identification Number (IIN or BIN): they identify the network and the issuing bank.

Is the CVV part of the card number?

No. The CVV is printed separately and can’t be calculated from the card number. Merchants must not store it after authorization.

What format is the expiry date?

MM/YY on the card, for example 08/29. The card is valid until the last day of that month. Payment APIs usually take the month and a 4-digit year as separate fields.

Related tools

Advertisement