Credit Cards

How to Read a Credit Card Number: BIN, Luhn, Brand and Format

PAYATE Team· · 3 min read
HPAYATE

A credit card number looks like a random string of digits, but it is actually a structured code. Once you know how it is built, you can tell the brand, the issuing bank, and whether a number was typed correctly — all from the digits themselves. Here is how to read one.

The three parts of a card number

Every card number is made of three sections:

  • IIN / BIN — the first 6 to 8 digits (the Issuer Identification Number, also called the Bank Identification Number). This identifies the scheme, the issuing bank and the country.
  • Account number — the middle digits that identify your specific account within that bank.
  • Check digit — the final single digit, a Luhn checksum over everything before it.

You can see all three at a glance with the Format tab of the Card Toolkit: paste a number and it shows the brand, the BIN, the digit count and the Luhn result.

How the brand is detected

The leading digits map to a scheme:

  • 4 → Visa
  • 51–55 and 2221–2720 → Mastercard
  • 34, 37 → American Express
  • 6011, 65, 644–649 → Discover
  • 35 → JCB  ·  36/38/30 → Diners Club  ·  62 → UnionPay

To go beyond the brand and find the issuing bank and country, look up the BIN with the BIN Lookup.

The Luhn check digit

The last digit is calculated with the Luhn algorithm. Starting from the right, every second digit is doubled (and if the result is over 9, you subtract 9), then all digits are summed. A valid number makes that sum a multiple of 10. This single digit catches the most common data-entry mistakes — a mistyped digit or two digits swapped — instantly.

Remember: passing Luhn means the number is well-formed, not that the card is real or active. Verifying a number is what the Card Validator does.

Grouping and masking

Cards are displayed in groups for readability. The two common patterns are:

  • 4-4-4-4 for 16-digit cards (Visa, Mastercard, Discover)
  • 4-6-5 for 15-digit American Express cards

When you need to show a card reference safely — in a receipt, a support ticket or a screenshot — you mask all but the last four digits, e.g. •••• •••• •••• 1234. The Format tab of the Card Toolkit does both grouping and masking in one click.

Why this matters

Reading a card number correctly powers a lot of everyday payment work: detecting the brand to show the right logo, validating input before you send it to a gateway, flagging an unusual length, and storing only a masked reference. None of it requires contacting a bank — it is all in the structure of the number.

Try it

Open the Card Toolkit, paste any card number into the Format & Check tab, and watch it break down the brand, BIN, length and Luhn status live — or switch to Generate to create Luhn-valid dummy numbers for QA.

Frequently asked questions

What do the first digits of a card number mean?
The first 6–8 digits are the IIN/BIN — the Issuer Identification Number. They identify the card scheme (Visa, Mastercard, etc.) and the issuing bank and country.
How many digits is a credit card?
Most cards are 16 digits. American Express is 15, Diners Club is 14, and some cards run up to 19 digits.
What is the last digit for?
The final digit is the Luhn check digit — a checksum over all the other digits that catches typos and transposed numbers.
Why is Amex grouped 4-6-5 instead of 4-4-4-4?
American Express cards have 15 digits and are conventionally displayed in a 4-6-5 pattern, while most 16-digit cards are shown as four groups of four.

Try the tools

P
Written by PAYATE Team

The PAYATE team builds free tools for merchants and developers.

More PAYATE tools