What the Luhn check catches
The last digit of every payment card number is a check digit computed with the Luhn algorithm (ISO/IEC 7812). It detects every single-digit typo and almost every swap of two adjacent digits, so payment forms use it to reject mistyped numbers before contacting the bank. IMEI numbers, Canadian social insurance numbers and many loyalty cards use the same check.
A number that passes is only well-formed. It does not mean the card exists, belongs to anyone or can be charged; only the issuing bank can tell that.
Worked example
Take 4111 1111 1111 1111, Visa's well-known test number. From the right, double every second digit: the eight doubled 1s become 2s (sum 16), the other eight 1s stay (sum 8, including the final check digit 1). The total is 24… plus the leading 4 doubled to 8 instead of a 1 doubled to 2: 16 − 2 + 8 + 8 = 30, a multiple of 10, so the number is valid. Change the last digit to 2 and it fails.
Privacy
Validation runs in your browser and nothing is stored or sent. For testing payment flows, use your processor's test card numbers rather than a real card.
How this works
The page removes spaces and hyphens and applies the Luhn algorithm from ISO/IEC 7812-1: starting from the rightmost digit, every second digit is doubled, 9 is subtracted from any result above 9, and all digits are summed. The number is valid when the sum ends in 0. The page also computes which check digit would make the rest of the number valid, and matches the first digits against the public issuer ranges of Visa, Mastercard, American Express, Discover, JCB, Diners Club, Elo, Hipercard and UnionPay. Nothing leaves your browser.
Frequently asked
Does a valid result mean the card is real?
No. It only means the number has a correct check digit. Only the issuing bank can confirm a card exists.
Is it safe to type my card number here?
Validation runs entirely in your browser and nothing is sent or stored. Still, there is no need to use a real card: test numbers work.
What else uses the Luhn algorithm?
IMEI phone numbers, Canadian SIN numbers, many gift and loyalty cards and some national ID schemes.
How is the card brand detected?
From the first digits, the issuer identification number, using published ranges such as 4 for Visa and 51–55 or 2221–2720 for Mastercard.
Sources
- ISO/IEC 7812-1:2017 — Identification cards, numbering system (Luhn check digit)
- The Unicode Standard, latest version
- Wikipedia — Luhn algorithm
Reviewed Oct 17, 2026 · test vectors fixtures/codes/credit-card-validator/