Tools

Luhn Checker

Check whether a card number passes the Luhn (mod 10) check, calculate the check digit for a partial number, and see every step of the calculation. Also shows the card brand from the first digits.

Test data only. Everything runs in your browser and nothing is sent anywhere, but use test card numbers, never real ones.
Spaces and dashes are ignored.

Result

Each digit, from the left. Highlighted digits are doubled (and reduced by 9 if over 9); the small number is what goes into the sum.

How the Luhn check works

The algorithm

Starting from the rightmost digit, the check digit, double every second digit moving left. If doubling gives more than 9, subtract 9. Add all the digits together. The number is valid if the total is a multiple of 10.

Calculating a check digit

Run the same steps on the number without its last digit, doubling the rightmost digit first. The check digit is what you must add to make the total a multiple of 10: (10 − total mod 10) mod 10.

What it catches, and what it does not

The Luhn check detects any single wrong digit and most swaps of two adjacent digits, which makes it good for catching typing mistakes. It is not a security check: a number that passes is not necessarily a real or active card.

Where it appears in EMV

The PAN on the chip, tag 5A, and in Track 2 Equivalent Data, tag 57, carries the same check digit as the embossed number. Our TLV parser runs this check when it decodes those tags. The check digit is also why ISO 0 and ISO 3 PIN blocks use the 12 rightmost PAN digits excluding it; see the PIN block calculator.

Card brand

The brand is guessed from the leading digits using the main published ranges: Visa (4), Mastercard (51–55, 2221–2720), American Express (34, 37), Discover (6011, 644–649, 65), JCB (3528–3589), UnionPay (62), Diners Club (300–305, 36, 38–39) and Maestro (50, 56–69 where not listed above). Real routing uses full BIN tables, so treat it as a hint.