Luhn Check Digit Tool
Use this calculator to generate a Luhn check digit for a base number, or validate a full number that already includes a check digit.
Generate Check Digit
Validate Full Number
What is a Luhn check digit?
The Luhn algorithm (also called the modulus 10 or mod 10 algorithm) is a lightweight checksum formula used to detect common data-entry errors. It is widely used for card numbers and account identifiers where a quick validation step is useful.
A check digit is the final digit appended to a base number. That last digit is calculated from the rest of the digits using the Luhn rules. If the number is mistyped, the validation step usually fails.
How this luhn check digit calculator works
1) Generate mode
Enter a base number (without the final check digit), and the calculator computes the missing check digit. It also returns the complete number.
2) Validation mode
Enter a complete number. The calculator runs the Luhn checksum and tells you whether the number is valid. If invalid, it shows the expected check digit for the base portion.
Step-by-step Luhn algorithm
- Starting from the right, move left and double every second digit.
- If doubling creates a number greater than 9, subtract 9 from it.
- Sum all digits.
- If total modulo 10 equals 0, the number is valid.
To generate a check digit, we compute the total as if the final digit is unknown, then choose the digit that makes the total divisible by 10.
Example
Suppose your base number is 7992739871.
- Calculated check digit: 3
- Complete number: 79927398713
If you run validation on 79927398713, it passes the Luhn check.
Where Luhn is commonly used
- Credit and debit card number validation
- Payment token and identifier sanity checks
- Government and telecom identifiers in some regions
- Internal product or account reference numbers
Important limitations
The Luhn algorithm is for error detection, not security. It can catch many accidental mistakes (like single-digit typos), but it does not protect against fraud or intentional manipulation.
- It is not encryption.
- It does not verify that an account is real, active, or funded.
- It should be combined with server-side checks and business rules.
Developer note
If you are implementing this in software, sanitize user input so that spaces and dashes are ignored. The calculator on this page already does that by stripping non-digit characters before calculation.
// Pseudocode
digits = onlyDigits(input)
sum = 0
parity = length(digits) % 2
for i in 0..length-1:
d = int(digits[i])
if i % 2 == parity:
d = d * 2
if d > 9: d -= 9
sum += d
valid = (sum % 10 == 0)
FAQ
Can I include spaces or dashes?
Yes. The calculator ignores separators and uses digits only.
What length should the number be?
Luhn itself does not enforce one length. Different industries define their own length rules.
Does a valid Luhn result mean the card/account exists?
No. It only means the number format is mathematically consistent with the Luhn checksum.