Skip to content
CardTools

Luhn Check Digit Calculator

Validate a number, compute a missing check digit, or find the typo that broke it.

Runs entirely in your browser. Nothing you paste is uploaded, logged or stored.

including the check digit
Luhn (ISO/IEC 7812-1 Annex B) is a checksum, not a security control. It is designed to catch keying mistakes — nothing more. It is also used on IMEIs, some national ID numbers and SIM ICCIDs, so a passing number is not necessarily a card.

The algorithm

Starting from the rightmost digit and moving left, double every second digit. If a doubled value exceeds 9, subtract 9 from it (equivalently, add its two digits together). Sum everything. If the total is divisible by 10, the number passes.

When you are computing a check digit rather than validating one, the doubling pattern shifts by one position — because the digit you are about to append occupies the rightmost slot. This is the single most common implementation bug, and it is why the working shown above highlights which positions were doubled.

What it catches

Luhn detects every single-digit error, and most transpositions of adjacent digits. Its notable blind spot is swapping 09 for 90, which it cannot see. That is a deliberate trade-off: it was designed in the 1950s to catch human keying mistakes cheaply, and it does that well.

It is a checksum, not a security control. It offers no protection against a deliberately constructed number, because constructing one takes a single line of code.

Not just card numbers

The same algorithm validates IMEI numbers on mobile phones, SIM ICCIDs, some national identification numbers, and various national provider identifiers. So a number passing Luhn is not evidence that it is a card — check the length and range too, which is what the PAN validator does.

Where it sits in the spec

For card numbers, Luhn is specified in ISO/IEC 7812-1 Annex B. The check digit is always the final digit of the PAN and is included in the total length — so a 16-digit Visa number has 15 digits of IIN and account identifier, plus the check digit.

More Card numbers tools