Cadmeo

Credit Card Validator

Use a test number. Never type a real card number into a web page you did not write.

The number is structurally valid

It passes the Luhn checksum and its length matches its prefix. That means it is well formed, not that the card exists, is active, or has funds.

Visa
Brand from prefix
16
Digits
13 or 16 or 19
Expected length
0
Luhn remainder

Nothing leaves your browser

The check is arithmetic on the digits, done in this page. No network request is made. Even so, a validator is for test numbers and for catching a typo in a form you are building, not for checking a real card.

The validator checks whether a card number is structurally valid: the Luhn checksum, the length, and the brand implied by the leading digits. It proves the number is well formed. It cannot tell you the card exists, is active or has funds, and no tool that runs in a browser can.

How it works

The Luhn algorithm, patented by Hans Peter Luhn in 1954, is a checksum designed to catch typing mistakes rather than fraud. Working from the right, every second digit is doubled; any result above 9 has 9 subtracted; the digits are summed, and a valid number totals a multiple of 10.

  1. Start from the rightmost digit and work left.
  2. Double every second digit.
  3. If doubling gives a number above 9, subtract 9 from it, the same as adding its two digits together.
  4. Add up all the digits.
  5. The number is valid when the total divides by 10 exactly.
  • Visa numbers start with 4 and run to 13, 16 or 19 digits.
  • Mastercard starts 51 to 55 or 2221 to 2720, always 16 digits.
  • American Express starts 34 or 37 and is 15 digits.
  • Discover starts 6011, 644 to 649 or 65.

Luhn catches every single-digit error and almost every transposition of two adjacent digits. The two mistakes people actually make typing a long number. It catches nothing about whether a bank issued the number.

Examples

The standard test number

Number

4111 1111 1111 1111

Result

Valid · Visa · 16 digits · Luhn remainder 0

This is the number every payment processor publishes for testing. It passes Luhn and belongs to no account.

One digit changed

Number

4111 1111 1111 1112

Result

Invalid: the checksum does not pass

Exactly what Luhn is for. Any single wrong digit breaks the total, which is why a form can reject a typo before contacting the bank.

The right length, the wrong brand

Number

A 16-digit number starting 34

Result

Invalid: American Express numbers are 15 digits

The prefix and the length have to agree. A 34 prefix means Amex, and Amex is always 15.

Frequently asked questions

Does passing mean the card is real?

No. It means the digits are internally consistent. Roughly one in ten random numbers of the right length passes Luhn by chance, and a passing number may belong to no account at all. Only the issuing bank can say whether a card exists, and only an authorisation request can say whether it works.

Is it safe to type a card number here?

The arithmetic runs in this page and makes no network request, so nothing is transmitted. That said, the honest advice is not to type a real card number into any web page that is not a payment form you trust. Use the published test numbers instead.

Why does the Luhn check exist at all?

To catch typing errors cheaply. It was designed in 1954 so a clerk could verify a number without a lookup, and it still saves a round trip to the bank for every mistyped digit. It is a checksum, never a security measure. Anyone can generate numbers that pass it.

What does the remainder tell me?

It is the Luhn total modulo 10. Zero means valid. A non-zero remainder tells you how far the checksum is from correct, which is occasionally useful when debugging a generator, but it does not identify which digit is wrong.

Why is the brand shown separately from the verdict?

Because a number can pass Luhn and still have a length its prefix does not allow, or a prefix no scheme uses. Showing the brand separately makes it clear which of the two checks failed rather than giving one unexplained "invalid".

Can it validate the CVV or the expiry date?

No. A CVV is computed from the card number, expiry and a bank-held key, so it can only be verified by the issuer. An expiry date is a plain date check with no relationship to the number.

Compared with