How to use the luhn algorithm calculator
- Enter your digit string in the input field. Spaces and hyphens are removed automatically.
- Choose Validate to act as a luhn checker, or Compute check digit to use the tool as a luhn check digit calculator.
- Read the result rows for validity or the computed digit.
- Review the steps table below the result to see exactly how each digit was doubled and summed.
How the Luhn Algorithm Works
The Luhn algorithm, also called the mod 10 algorithm, is a simple formula used to validate identification numbers. A luhn checksum calculator applies these rules:
- Starting from the rightmost digit, double every second digit. When you validate a full number, the rightmost digit is the check digit and is not doubled.
- If doubling produces a number greater than 9, subtract 9 from it (equivalently, add the two digits of the product together).
- Sum all the resulting digits.
- If the total modulo 10 equals zero, the number is valid.
For example, take the payload 7992739871 and compute its check digit. Because the check digit will be appended on the right, the rightmost payload digit sits in a doubled position. Reading the digits from the right gives 1, 7, 8, 9, 3, 7, 2, 9, 9, 7. Doubling every second digit starting with the first gives 2, 7, 16, 9, 6, 7, 4, 9, 18, 7. After subtracting 9 from the values over 9 we get 2, 7, 7, 9, 6, 7, 4, 9, 9, 7, and the sum is 67. The check digit is (10 - 67 mod 10) mod 10 = 3. Appending 3 gives 79927398713. Validating that number doubles a different set of digits and gives a total of 70, which is divisible by 10, so it passes.
Common Uses for Luhn Validation
The Luhn formula is not a cryptographic hash. It is a simple error-detection code designed to catch single-digit mistakes and most adjacent-digit transpositions. You will find it in many systems:
- Payment cards: Visa, Mastercard, American Express and Discover all use Luhn as the final digit check. Developers often use a luhn checker during form validation before sending data to a payment gateway.
- IMEI numbers: Every mobile phone has a 15-digit International Mobile Equipment Identity validated by mod 10.
- Canadian Social Insurance Numbers (SIN): The last digit is a Luhn check digit.
- NPI numbers: US National Provider Identifiers use Luhn with the prefix 80840 added in front of the 10-digit number, so add that prefix to the digits before you check one here.
This tool acts as a general-purpose luhn algorithm calculator for any of these formats. Simply paste the digits and choose validate or compute. A number that passes the check is only well formed; it does not prove a card, phone or ID exists.
Reading the Steps Table
When you enter a number, the tool generates a table showing each digit, whether it was doubled, the intermediate value after doubling (and subtracting 9 if needed), and the running contribution to the total sum. This transparency is what makes a good luhn checksum calculator useful for debugging: you can trace exactly where a transposition or typo occurred.
The table processes digits from left to right but determines which positions to double based on their distance from the right end, matching the specification. For validation mode, the rightmost digit is treated as the existing check digit and is not doubled. For compute mode, the rightmost digit of your input is considered part of the payload, so the doubling pattern shifts accordingly.
Limitations of the Luhn Formula
While the Luhn algorithm catches all single-digit errors and nearly all transpositions of adjacent digits, it has known blind spots. It will not detect the transposition of 09 to 90 or vice versa, because both contribute 9 to the sum. It also cannot catch certain twin-digit substitutions like 22 to 55.
For stronger error detection, systems sometimes combine Luhn with length checks, prefix checks (like the Major Industry Identifier on payment cards) or more robust algorithms such as Verhoeff or Damm. If you need a different approach, explore our checksum calculator for other methods. However, for everyday development tasks involving card numbers, IMEIs or SINs, this luhn check digit calculator covers the standard requirement completely.
Reference: Quick Validation Examples
Use this table to verify your own implementation against known values. Each row shows a payload, the expected check digit and the complete valid number.
| Payload | Check Digit | Valid Number | Total Sum |
|---|---|---|---|
| 7992739871 | 3 | 79927398713 | 70 |
| 411111111111111 | 1 | 4111111111111111 | 30 |
| 49015420323751 | 8 | 490154203237518 | 60 |
| 0 | 0 | 00 | 0 |
| 123456789 | 7 | 1234567897 | 50 |
You can paste any of these into the input field above to confirm the luhn checker produces the same results.
Worked examples
| Example | Input | Result |
|---|---|---|
| Validate test number | Number (digits only): 79927398713; Mode: validate | Valid: Yes; Total sum: 70; Check digit: 3 |
| Compute check digit | Number (digits only): 7992739871; Mode: compute | Check digit: 3; Complete number: 79927398713; Sum before digit: 67 |
| Visa test card | Number (digits only): 4111111111111111; Mode: validate | Valid: Yes; Total sum: 30; Check digit: 1 |
| IMEI example | Number (digits only): 490154203237518; Mode: validate | Valid: Yes; Total sum: 60; Check digit: 8 |
FAQ
What is a luhn checksum calculator?
A luhn checksum calculator applies the Luhn mod 10 formula to a string of digits to determine whether the number passes the checksum test. It is commonly used to validate payment card numbers, IMEI codes and government identifiers before processing them.
How do I compute a Luhn check digit?
Append a zero to your payload, run the Luhn sum, then calculate (10 minus (sum mod 10)) mod 10. That result is the check digit. This tool automates that process when you select the compute mode.
Does this luhn checker work for credit card numbers?
Yes. All major payment card networks use the Luhn algorithm for the final digit. Enter the full card number in validate mode to check it. Note that passing Luhn does not mean the card is real or active, only that the number is formatted correctly.
Can the Luhn algorithm catch all typos?
It catches every single-digit error and almost all adjacent-digit transpositions. However, it cannot detect swapping 09 with 90, or certain other specific two-digit patterns.
Is my data sent to a server?
No. This luhn algorithm calculator runs entirely in your browser. Nothing you type is uploaded anywhere.
What is the difference between validate and compute modes?
Validate treats the last digit as an existing check digit and verifies the whole number sums to a multiple of 10. Compute treats the entire input as a payload and calculates which digit should be appended to make it valid.
Can I use this for IMEI or SIN validation?
Yes. Both IMEI numbers and Canadian Social Insurance Numbers use the exact same Luhn mod 10 algorithm. Paste the digits without spaces or hyphens and select validate.