Luhn Algorithm Validator
Validate any credit card, IMEI, or ID number using the Luhn algorithm checksum.
Identifies Visa, Mastercard, American Express, Discover, and Diners Club.
Luhn Algorithm (Mod 10)
The Luhn algorithm is a simple checksum formula used to validate identification numbers. It was created in 1954 by Hans Peter Luhn, a German-American computer scientist at IBM.
The algorithm is used to validate:
- Credit and debit card numbers (Visa, Mastercard, American Express, Discover)
- IMEI (International Mobile Equipment Identity) numbers, which identify mobile phones
- National identification numbers in some countries
- Canadian Social Insurance Numbers
How it works (step by step):
Starting from the rightmost digit (the check digit) and moving left:
- Leave every second digit unchanged (positions 1, 3, 5… from the right)
- Double every other digit (positions 2, 4, 6… from the right)
- If doubling produces a number > 9, subtract 9 from it
- Sum all digits
- If the total sum mod 10 = 0, the number is valid
Worked example, card number 4532015112830366:
Position (from right): 1→6, 2→6×2=12→3, 3→3, 4→0×2=0, 5→3, 6→8×2=16→7, 7→2, 8→1×2=2, 9→1, 10→5×2=10→1, 11→1, 12→0×2=0, 13→2, 14→3×2=6, 15→5, 16→4×2=8
Sum = 6+3+3+0+3+7+2+2+1+1+1+0+2+6+5+8 = 50. 50 mod 10 = 0 → Valid!
Card type detection by prefix:
| Card Type | Prefix |
|---|---|
| Visa | Starts with 4 |
| Mastercard | Starts with 51-55 or 2221-2720 |
| American Express | Starts with 34 or 37 |
| Discover | Starts with 6011, 622126-622925, 644-649, or 65 |
| Diners Club | Starts with 300-305, 36, or 38 |
Read those as numeric ranges, not text prefixes, because the difference bites. Mastercard’s second block is 2221 to 2720, so 2200 is not a Mastercard even though it starts with 22. Discover’s is 622126 to 622925, so 622100 is not a Discover even though it starts with 6221. Plenty of validators get this wrong by treating the range as a string match, and the result is a card that gets labelled as the wrong network.
Important: The Luhn algorithm detects accidental errors, not deliberate fraud. A number passing the Luhn check does not mean it is a real, active account number.
How we build and check this calculator
This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.
SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.