Luhn Algorithm Checker

Luhn only validates the check digit, not that the card is active.

The Luhn algorithm (ISO/IEC 7812-1) is the checksum that protects credit card numbers, IMEI device identifiers, Canadian SINs, US NPIs and a handful of other numbering schemes against single-digit typos. Paste a digit string, spaces and dashes are ignored, and the checker shows whether the number passes and walks through the doubling and summing steps so you can verify it by hand if you want.

How the Luhn check is computed

  1. 1

    Strip non-digits

    Spaces, dashes and dots are removed. Only digits 0–9 count.

  2. 2

    Double every second digit from the right

    Starting with the second-to-last, every alternate digit is doubled.

  3. 3

    Sum the digits of each doubled value

    If doubling gives 14, add 1 + 4 = 5. Equivalent to subtracting 9 from any double ≥ 10.

  4. 4

    Total all resulting values

    Add the doubled-and-reduced digits plus the untouched digits.

  5. 5

    Check divisibility by 10

    If the total ends in 0, the number passes. Otherwise it's invalid.

Worked example

Check 4539 1488 0343 6467:

Pos (right→left) Digit Doubled? Value
1 7 no 7
2 6 yes 12 → 3
3 4 no 4
4 6 yes 12 → 3
5 3 no 3
6 4 yes 8
7 3 no 3
8 0 yes 0
9 8 no 8
10 8 yes 16 → 7
11 4 no 4
12 1 yes 2
13 9 no 9
14 3 yes 6
15 5 no 5
16 4 yes 8

Total: 80. 80 mod 10 = 0 → valid.

Where Luhn is used

System Length Luhn-protected?
Visa, Mastercard, Discover 13–19 digits yes
American Express 15 digits yes
IMEI (GSM device ID) 15 digits yes
Canadian Social Insurance 9 digits yes
US National Provider Identifier 10 digits yes
Israeli ID (Teudat Zehut) 9 digits yes
ISBN-13 13 digits no (uses mod 10 with weights 1,3)

What Luhn detects and misses

  • Detects: all single-digit errors, most (but not all) transpositions of adjacent digits.
  • Misses: the transposition 09 ↔ 90 and several similar pairs. It’s a typo check, not a security check.
  • Not a security feature. A Luhn-valid number is easy to generate. PAN validation at payment gateways uses issuer ranges, CVV, AVS and 3-D Secure, not just Luhn.

Frequently Asked Questions

No. Luhn only verifies the number is mathematically well-formed. It says nothing about whether the card has been issued, has funds, or is stolen. Real validation happens at the issuer during authorization.

Yes, the last digit is the check digit and can always be chosen to make the sum divisible by 10. That’s how IMEI generators and test card numbers work.

It catches every single-digit substitution and most adjacent-digit transpositions, but a few pairs (like 09 ↔ 90) leave the checksum unchanged. More robust schemes (ISBN-13, Verhoeff, Damm) trade complexity for extra error coverage.

The checker runs entirely in your browser, so nothing is transmitted, but pasting live PAN data anywhere you don’t have to is bad habit. Use test numbers (e.g., 4242 4242 4242 4242) when experimenting.

Luhn works on any length but is standardised for specific schemes (usually 9–19 digits). The checker doesn’t cap the length.

Related Tools

Tool available in other languages