Luhn Check Digit Calculator
Luhn Check Digit Calculator
The Luhn algorithm — also called the "mod 10" algorithm — is a simple checksum formula used to validate a wide range of identification numbers. It was created by Hans Peter Luhn, an IBM scientist, and patented in 1960. Today it protects credit card numbers, IMEI device identifiers, Canadian social insurance numbers, Israeli ID numbers, and many other identification schemes. [wikipedia-luhn]
The algorithm catches a specific and very common class of errors: a single mistyped digit, or two adjacent digits swapped. Those two error types account for the overwhelming majority of transcription mistakes people make when typing long numbers, which is exactly why the Luhn formula has survived for more than sixty years while many more complex schemes have come and gone.
A number that passes the Luhn check is not necessarily valid in the sense of belonging to a real card. The algorithm detects transcription errors; it does not verify that an account exists, has funds, or was issued by any particular institution. Fraudsters routinely generate numbers that pass the Luhn check but correspond to no real account — which is why online payment systems run the check as a first-pass sanity filter, then contact the issuer to verify the number truly exists.
This calculator has two modes. Validate Number takes a full number and reports whether it passes the Luhn check, including the running sum. Generate Check Digit takes the body digits before the check digit and computes what the final digit must be for the number to pass — the classic way to build a valid number from an account prefix.
If you work with card numbers regularly, the Credit Card Calculator covers interest, payments, and payoff timelines, while the Modulo Calculator explains the modular arithmetic at the heart of this algorithm.
Choose a mode and enter your number. Digits, spaces, and dashes are all accepted; the calculator strips spaces and dashes automatically.
Validate Number mode
Select Validate Number and type the complete number you want to check, such as 4532 0112 3456 7896. The calculator immediately reports whether the number passes the Luhn check. It also shows the check digit (the final digit), the total Luhn sum, and the number of digits counted.
A VALID verdict means the number satisfies the Luhn checksum — the first-pass filter used by payment systems. An INVALID verdict means a digit is wrong, digits are swapped, or the number was fabricated without applying the algorithm.
Generate Check Digit mode
Select Generate Check Digit and enter the digits that come before the check digit. For example, if a card body is 7992739871, the calculator computes that the check digit must be 3 for the full number 79927398713 to pass. This mode is useful when you know an account prefix and need to construct a number that will pass the Luhn filter, or when you are debugging a batch of IDs where one check digit is wrong.
Example 1: A known-valid number
Enter 79927398713 in Validate mode. The check digit is 3, the Luhn sum is 70, and 70 mod 10 = 0, so the number is VALID. This is the canonical example used throughout the Luhn literature. [unb-luhn]
Example 2: A single-digit typo
Enter 79927398714 — changing only the final digit from 3 to 4. The Luhn sum becomes 71, which is not divisible by 10, so the number is INVALID. One keystroke, caught instantly.
Example 3: Swapped adjacent digits
Enter 79927398731 — the last two digits, 3 and 1, are swapped relative to the valid 79927398713. The algorithm flags this as INVALID too, demonstrating why Luhn is considered good at detecting transposition errors.
Example 4: Generating a check digit
Switch to Generate mode and enter 7992739871. The calculator returns a check digit of 3 and the complete number 79927398713. Append any other digit and the full number will fail validation.
The Luhn algorithm processes the number from the rightmost digit (the check digit itself) moving left. Starting with the check digit position and alternating, every second digit is doubled; if doubling produces a two-digit number, the two digits are summed (equivalently, subtract 9). All the resulting values are added together. The number passes if the total is a multiple of 10. [iso7812]
Formally, for a number with digits d₁, d₂, ..., dₙ reading from the left, let the rightmost digit be position 1. For every digit in an even position counting from the right (positions 2, 4, 6, ...), double it, and if the result exceeds 9, sum its digits:
Then the number is valid when:
The check digit itself is never doubled — it sits in position 1 and is added normally.
Worked example: 79927398713
Take the canonical example 79927398713 and label the digits from the right. The steps are:
| Position (from right) | Digit | Doubled? | Value Added |
|---|---|---|---|
| 1 | 3 | No | 3 |
| 2 | 1 | Yes (2) | 2 |
| 3 | 7 | No | 7 |
| 4 | 8 | Yes (16 → 1+6) | 7 |
| 5 | 9 | No | 9 |
| 6 | 3 | Yes (6) | 6 |
| 7 | 7 | No | 7 |
| 8 | 9 | Yes (18 → 1+8) | 9 |
| 9 | 9 | No | 9 |
| 10 | 7 | Yes (14 → 1+4) | 5 |
| 11 | 7 | No | 7 |
Sum: 3 + 2 + 7 + 7 + 9 + 6 + 7 + 9 + 9 + 5 + 7 = 70. Since 70 is a multiple of 10, the number is valid. [technickenormy]
How the check digit is computed
To generate a check digit, run the same process on the body digits but leave the final position as an unknown. Compute the Luhn sum of the body with the "virtual" check-digit position held at 0 (meaning the last digit is not doubled), then the check digit is the smallest value c such that (sum + c) mod 10 = 0, namely c = (10 - sum mod 10) mod 10. For the body 7992739871 the resulting sum is 67, so c = (10 - 7) = 3.
Different checksums catch different fractions of the errors people actually make. The table compares the Luhn algorithm with simpler and more complex alternatives. [wikipedia-luhn]
| Scheme | Single-digit errors | Transpositions | Notes |
|---|---|---|---|
| No check | 0% | 0% | Nothing is detected |
| Digit-sum (mod 9) | Catches ~78% | ~0% | Too weak for IDs |
| Luhn (mod 10) | 100% | ~89% (all adjacent pairs that do not differ by 9) | The industry standard |
| Verhoeff | 100% | 100% | Stronger, used in some serial schemes |
Luhn catches all single-digit errors and detects transpositions between any two adjacent digits whose values differ — roughly 89% of all adjacent swaps. The only adjacent transpositions it misses are pairs like "09" → "90" or "18" → "81" where the two digits differ by 9. Verhoeff's algorithm improves on this but is rarely used for consumer IDs because Luhn's simplicity and backward compatibility matter more than the marginal improvement.
- Use it as a first filter, not a verdict. A passing Luhn check means the number was typed correctly, nothing more. It never confirms the account exists. Always treat Luhn-passing numbers in the wild as potentially fabricated.
- Never store or post full card numbers. Even a Luhn-valid number you test here could be a real card. This calculator processes numbers in your browser and does not store anything, but you should still avoid pasting real card data into shared machines.
- Let the check digit do the work. If you are generating account numbers or employee IDs, compute the check digit algorithmically with this tool rather than letting a human invent the last digit. The generated number will be Luhn-valid by construction.
- Understand what the check digit protects against. The Luhn digit is designed to catch typos and swaps, not malicious tampering. A deliberate forger can easily produce Luhn-valid numbers, so the check digit is a data-integrity feature, not a security feature.
- Combine with issuer prefixes. Card schemes use known prefix ranges: Visa cards start with 4, Mastercard with 51-55 and 2221-2720, and so on. You can pair a Luhn check with prefix validation using the Big Number Calculator for the arithmetic. [wikipedia-payment-card]
- Check length too. A number can pass Luhn and still be the wrong length for its scheme. Always verify the digit count alongside the checksum when validating card data.
- Detects transcription errors only. The Luhn algorithm cannot distinguish a genuine account number from a randomly generated number that happens to satisfy the checksum. It has no way to know whether an account exists.
- Not a security mechanism. The check digit provides no protection against intentional forgery. Anyone can compute a valid check digit with this very calculator; the algorithm is an integrity check, not an authentication method.
- Misses some transpositions. Adjacent transpositions where the two digits differ by exactly 9 (such as 09 → 90) are not detected. In practice this is a tiny fraction of real typos, but it is a documented gap. [wikipedia-luhn]
- Scheme-specific rules not included. This tool validates the checksum only. It does not verify IIN prefixes, digit-length rules, or checksum variations used by specific card schemes or national ID systems. Those rules vary by issuer.
- Non-numeric input rejected. Letters and symbols are not part of the Luhn scheme. If your ID format includes letters (as some do), this calculator cannot validate it.
- ❓ What is the Luhn algorithm?
- ✅ The Luhn algorithm, also called mod 10, is a checksum formula used to validate identification numbers such as credit cards and IMEI codes. It catches single-digit typos and most adjacent transpositions by summing a weighted version of the digits and checking for a multiple of 10.
- ❓ Does a valid Luhn check mean the card is real?
- ✅ No. Passing the Luhn check only means the number is internally consistent. It does not confirm the account exists, has funds, or was issued by any bank. Payment systems use Luhn as a first filter and then contact the issuer to verify the account.
- ❓ How do I calculate a Luhn check digit?
- ✅ Start from the right and double every second digit, summing the digits of any result over 9. Add everything together. The check digit is (10 - sum mod 10) mod 10. The Generate mode in this calculator does it automatically.
- ❓ What numbers use the Luhn algorithm?
- ✅ Credit and debit card numbers, IMEI device identifiers, Canadian social insurance numbers, Greek and Israeli national ID numbers, and many membership and account numbering schemes. The ISO/IEC 7812 standard specifies it for payment card identification.
- ❓ Why does doubling 16 give 7 instead of 16?
- ✅ When doubling produces a two-digit number, the algorithm sums the two digits (1 + 6 = 7), which is equivalent to subtracting 9. This keeps the contribution to the total within the range of single digits.
- ❓ What is the ISO 7812 standard?
- ✅ ISO/IEC 7812 is the international standard for the numbering system of identification cards, including the IIN (Issuer Identification Number), the account number format, and the Luhn check digit calculation described in its Annex B.
- ❓ Can two different numbers have the same check digit?
- ✅ Yes. The check digit is a single digit, so at most 10% of randomly chosen numbers can pass any given check digit scheme. Luhn detects most common errors, but many different bodies with different valid check digits exist.
- ❓ Why does the Luhn algorithm miss the transposition 09 to 90?
- ✅ When adjacent digits differ by 9, doubling and digit-summing their positions produces values whose contributions are identical, so the swapped pair adds the same amount to the total. The algorithm cannot distinguish the two orders.
- ❓ Is the Luhn algorithm used for anything besides cards?
- ✅ Yes. It validates IMEI numbers, Swedish personal identity numbers (partially), some national ID and social security numbering schemes, and various internal account-numbering systems where transcription error detection is valuable.
- ❓ Is this calculator safe to use with my real card number?
- ✅ Yes. The calculation runs entirely in your browser, and nothing is transmitted or stored. Even so, avoid typing real card numbers into shared devices as a general privacy practice.
References
- [1]International Organization for Standardization. (2017). ISO/IEC 7812-1:2017 — Identification cards — Identification of issuers — Part 1: Numbering system (Annex B, the Luhn formula).
- [2]IEC. (2017). ISO/IEC 7812-1:2017 preview (Annex B: Check digit calculation).
- [3]University of New Brunswick. (n.d.). The Luhn algorithm (ECE 4253 course notes).
- [4]Wikipedia. (n.d.). Luhn algorithm.
- [5]Wikipedia. (n.d.). Payment card number.
Last updated: July 31, 2026
UnByte — Independent Software Engineering
Every calculator references authoritative sources — Editorial policy