Last updated: August 1, 2026
Luhn Algorithm Calculator
Creators
Dharmendra SinghReviewers

Creators
Dharmendra SinghReviewers
Quick Answer
This Luhn algorithm calculator cleans a digit string, validates completed numbers with the mod-10 checksum, or generates the correct final check digit for a base number.
The Luhn algorithm doubles every second digit from the right, adjusts large doubled values, sums the results, and checks whether the total is divisible by ten.
Creators
Dharmendra SinghReviewers

Creators
Dharmendra SinghReviewers
Formula
Double every second digit from the right, subtract 9 when the doubled value exceeds 9, then sum all digits. A valid number has total mod 10 = 0.
Where:
- d_i=Original digit at position i(digit)
- d_i^*=Processed digit after Luhn doubling rules(digit)
- Σd_i^*=Checksum total
- 10=Modulus used for validation
Worked Examples
Validate a classic sample
Check whether 79927398713 is valid.
- 1Starting from the right, double every second digit.
- 2Subtract 9 from any doubled value above 9.
- 3Add all processed digits to get 70.
- 4Because 70 mod 10 = 0, the number is valid.
Generate a check digit
Create the final digit for base number 7992739871.
- 1Append a temporary zero to the base digits.
- 2Compute the Luhn total under the generation pattern.
- 3Choose the digit that makes the final total a multiple of 10.
- 4The correct check digit is 3.
Ignore separators
Validate a spaced or hyphenated number.
- 1Strip spaces and hyphens first.
- 2Run the standard Luhn doubling rule.
- 3Find the same checksum total as the plain number.
- 4Return the same validity result.
Catch an invalid number
Check a number with the wrong final digit.
- 1Process digits from the right.
- 2The checksum total is not a multiple of 10.
- 3The number fails the mod-10 test.
- 4Request correction or regeneration.
Introduction
The Luhn algorithm is a checksum rule used to detect common transcription mistakes in identifiers such as payment card numbers, IMEI values, and membership codes. It does not prove an account exists, but it quickly catches many mistyped numbers.
What the Luhn Rule Checks
Luhn validation confirms whether a number follows a mod-10 checksum pattern.
Catches many single-digit mistakes
Catches many adjacent transpositions
Works with any length of digits
Uses a simple alternating doubling pattern
The Doubling Pattern
From the rightmost end, every second digit is doubled before summing.
If doubling creates 10 to 18, subtract 9
Untouched digits are added directly
The final sum drives the check
The pattern changes depending on whether you already have a check digit
Validation Mode
Use validation when the last digit is already present and you want a pass/fail result.
Enter the full identifier
Separators are stripped automatically
Checksum total is reported
Validity is true only when total mod 10 is zero
Generation Mode
Use generation when you have the base digits only and need the correct final digit.
Append a placeholder zero internally
Compute the checksum total
Choose the digit that reaches the next multiple of 10
Return the completed number
How to Use the Calculator
Select a mode, paste the digits, and read the normalized result.
Pick validate or generate
Paste the number or base digits
Review cleaned digits
Read validity, total, and check digit
What the Algorithm Does Not Do
Luhn is a formatting check only; it does not authorize, identify an issuer, or confirm an account is open.
Not a security feature by itself
Does not detect every possible mistake
Does not validate expiration or issuer rules
Should be combined with domain-specific checks
Common Mistakes
Errors usually come from pasting non-digit text or using generate mode on a number that already includes a check digit.
Remove letters
Use generate only for base digits
Use validate for finished numbers
Do not confuse formatting success with real-world authorization
FAQs
Does passing Luhn mean a card or identifier is real?
No. It only means the digits satisfy the checksum rule.
Can I paste spaces or hyphens?
Yes. The calculator removes spaces and hyphens before processing the digits.
What if the input contains letters?
The calculator throws a validation error because only digits are allowed after cleanup.
When should I use generate mode?
Use generate mode when you have base digits only and need to compute the final check digit.
What checksum total counts as valid?
Any total that is evenly divisible by 10 passes the Luhn test.
Can the algorithm detect every typo?
No. It catches many common errors but not every possible digit rearrangement.
Why is the last digit called a check digit?
It is chosen specifically so the whole number satisfies the mod-10 checksum.