Luhn Algorithm Checker

Validate credit card numbers and IMEI via Luhn mod-10

Validates any number with the Luhn (mod 10) algorithm and computes the correct check digit. Works for credit cards, IMEI numbers and many national IDs, showing the weighted sum and why a number passes or fails. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is the Luhn algorithm?

The Luhn algorithm, also called mod 10, is a checksum formula that validates identification numbers such as credit cards and IMEIs. It doubles every second digit from the right, sums the digits, and a valid number has a total divisible by 10.

The Luhn algorithm (mod 10) is the check-digit formula behind credit card numbers, IMEI device identifiers and many national IDs. It exists to catch accidental typos and digit swaps before a number is processed. This checker validates any number and computes the correct check digit, entirely in your browser.

How it works

To validate a number that already includes its check digit:

  1. Starting from the rightmost digit, double every second digit.
  2. If a doubled value exceeds 9, subtract 9 (equivalently, add its two digits).
  3. Sum all the resulting digits. The number is valid if the total is divisible by 10.

To compute the check digit for a payload that has no check digit yet, run the same weighting as if a 0 were appended, then the check digit is (10 - (sum mod 10)) mod 10.

Step-by-step trace: working through the algorithm manually

Take the number 4 5 3 9 1 4 8 8 0 3 4 3 6 4 6 7. Process from right to left, doubling every second digit (positions 2, 4, 6, … from the right):

Position from right:   1  2   3  4   5  6   7  8   9  10  11  12  13  14  15  16
Digit:                 7  6   4  6   3  4   3  0   8   8   4   1   9   3   5   4
Double every 2nd:      7  12  4  12  3  8   3  0   8   16  4   2   9   6   5   8
Subtract 9 if >9:      7  3   4  3   3  8   3  0   8   7   4   2   9   6   5   8

Sum = 7+3+4+3+3+8+3+0+8+7+4+2+9+6+5+8 = 80, which is divisible by 10. Valid.

What Luhn catches and what it misses

Luhn is specifically designed to catch single-digit transcription errors — typing a 5 where a 6 should be — and most adjacent transpositions — swapping 46 to 64. It detects all single-digit errors without exception. For transpositions, it catches every case except swapping 0 and 9, which produce the same weighted value after the subtraction step.

What Luhn does not catch:

  • Multiple simultaneous errors that happen to cancel out
  • The specific 0↔9 transposition
  • Completely invented numbers that happen to pass (there are many valid Luhn numbers for any partial payload)

Where Luhn is used in practice

Number typeDigitsNotes
Visa credit card16Starts with 4
Mastercard16Starts with 51–55 or 2221–2720
American Express15Starts with 34 or 37
IMEI (mobile device)15Last digit is Luhn check digit
Canadian SIN9Social Insurance Number
ICCID (SIM card)18–19May or may not use Luhn depending on issuer

Notes

Luhn detects all single-digit errors and nearly all adjacent transpositions, with the lone exception of swapping a 0 and a 9. A passing result means the digits are internally consistent, not that the card or device was ever issued or is currently active — it is a format check only. Payment processors run additional checks against live card databases. Nothing you type is sent anywhere; the algorithm runs locally in your browser.