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, Amex, Discover)
- IMEI numbers (mobile phone identifiers)
- 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
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 |
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.