Luhn Check Digit Tool
Calculate the missing check digit or validate a complete number using the Luhn algorithm. Spaces and hyphens are ignored automatically.
1) Calculate a check digit
2) Validate a full number
Tip: Press Enter inside either input box to run that action quickly.
What is the Luhn digit?
The Luhn digit (also called a check digit) is a simple error-detection value added to the end of an identification number. It helps systems catch common typing mistakes before accepting a value. You often see this method used with payment cards, loyalty numbers, and some government or telecom identifiers.
The core idea is straightforward: the final digit is chosen so that the whole number satisfies a checksum rule. If one digit is entered incorrectly, or if two adjacent digits are swapped, the checksum usually fails and the number is rejected.
How this calculator helps
- Generate check digit: Enter a base number and get the correct Luhn digit instantly.
- Validate numbers: Confirm whether a full number passes the Luhn checksum.
- Input cleanup built in: You can paste values with spaces or dashes (for example, 1234-5678-9012).
How the Luhn algorithm works
Validation steps
- Starting from the rightmost digit, move left one digit at a time.
- Double every second digit (the second, fourth, sixth from the right, etc.).
- If doubling produces a number greater than 9, subtract 9 from it.
- Add all digits together.
- If total modulo 10 equals 0, the number is valid.
Generating a check digit
To generate a check digit, apply the same weighted sum logic to the base number (as if a final digit were going to be appended), then choose the digit that makes the total divisible by 10. That final digit is the check digit.
Example
For base number 7992739871, the calculated check digit is 3. The full valid number becomes 79927398713. If you change a digit, the checksum generally fails.
Why this matters in real systems
Luhn checking improves data quality by preventing many accidental input errors at the point of entry. It is fast, deterministic, and easy to implement in forms and backend validators. It reduces bad records and avoids unnecessary downstream failures caused by simple typos.
Important limitation
The Luhn algorithm is for error detection, not security. A passing number is not proof that an account is active, authorized, or real in any business sense. Always pair checksum validation with domain checks, issuer logic, and secure verification workflows where needed.
Best practices for developers
- Run Luhn checks on both client and server sides.
- Normalize input by stripping non-digit characters before processing.
- Return user-friendly error messages for invalid input.
- Never treat a checksum pass as authentication or fraud validation.
Quick FAQ
Does Luhn work for every identifier?
No. It only works for numbering systems designed to use the Luhn checksum.
Can two different numbers both pass Luhn?
Yes. Many numbers can pass. Luhn is not a uniqueness check.
Is this calculator storing what I type?
No. This page performs all calculations in your browser using JavaScript and does not send input to a server.