Luhn Algorithm Validator & Check Digit Calculator
Validate credit card numbers, IMEI codes, and other identifiers using the Luhn algorithm. Calculate check digits and detect card networks instantly.
About
The Luhn algorithm (also called the Modulus 10 or Mod 10 algorithm) is a checksum formula published by Hans Peter Luhn in 1954 via U.S. Patent 2,950,048. It detects single-digit transcription errors and most transpositions of adjacent digits in numeric identifiers. It is not a cryptographic hash. It does not protect against deliberate fraud. Its sole purpose is catching accidental corruption during manual entry. The algorithm operates in O(n) time where n is the digit count. Every major credit card network (Visa, Mastercard, American Express, Discover, JCB, UnionPay) requires the final digit of the Primary Account Number (PAN) to satisfy the Luhn check. IMEI numbers on mobile devices (15 digits, ITU-T E.212) also use it. Canadian Social Insurance Numbers, some national ID schemes, and ISBNs partially rely on similar modular arithmetic. A failed Luhn check means the number was corrupted during entry or is structurally invalid. A passing check does not guarantee the account exists or is active.
This tool performs the complete Luhn computation, shows the digit-by-digit breakdown so you can audit each step, detects the card network from IIN/BIN prefixes per ISO/IEC 7812, and can generate the correct check digit for an incomplete number. Limitation: prefix-based card detection covers published BIN ranges and may not identify every issuer sub-brand or co-branded cards.
Formulas
The Luhn algorithm processes a number string of n digits d1, d2, …, dn (where dn is the check digit, the rightmost). Starting from the rightmost digit and moving left, double every second digit:
di′ =
The total checksum is computed as:
S = n∑i=1 di′
The number is valid if and only if:
S mod 10 ≡ 0
To generate a check digit dn for a partial number d1 … dn−1, compute the Luhn sum S′ of the partial digits (treating the missing position as 0), then:
dn = (10 − (S′ mod 10)) mod 10
Where di = individual digit at position i, n = total number of digits, S = Luhn checksum, di′ = transformed digit after doubling rule.
Reference Data
| Card Network | IIN/BIN Prefix(es) | Length(s) | Check Algorithm | Example Prefix |
|---|---|---|---|---|
| Visa | 4 | 13, 16, 19 | Luhn | 4XXX |
| Mastercard | 51 - 55, 2221 - 2720 | 16 | Luhn | 5500 |
| American Express | 34, 37 | 15 | Luhn | 3782 |
| Discover | 6011, 644 - 649, 65 | 16 - 19 | Luhn | 6011 |
| JCB | 3528 - 3589 | 16 - 19 | Luhn | 3530 |
| Diners Club Carte Blanche | 300 - 305 | 14 | Luhn | 3000 |
| Diners Club International | 36 | 14 | Luhn | 3600 |
| Diners Club USA/Canada | 54 | 16 | Luhn | 5400 |
| UnionPay | 62 | 16 - 19 | Luhn | 6200 |
| Maestro | 5018, 5020, 5038, 6304 | 12 - 19 | Luhn | 5018 |
| Mir | 2200 - 2204 | 16 - 19 | Luhn | 2200 |
| Verve | 506099 - 506198, 650002 - 650027 | 16, 18, 19 | Luhn | 5061 |
| RuPay | 60, 65, 81, 82, 508 | 16 | Luhn | 6521 |
| IMEI (Mobile Device) | TAC (8 digits) + serial | 15 | Luhn | 3568... |
| Canadian SIN | 1 - 9 (province code) | 9 | Luhn | 046... |