The Luhn algorithm, also called the mod 10 or modulus 10 formula, is the small checksum hidden in the last digit of payment card numbers, IMEI phone identifiers, Canadian social insurance numbers and many loyalty and account numbers. It was patented by IBM engineer Hans Peter Luhn in 1960 and is specified today in ISO/IEC 7812-1. Its job is modest but useful: catch typing mistakes before a number is processed.
This Luhn algorithm calculator does two things. In Validate mode it tells you whether a full number passes the check and, if not, which final digit would have made it valid. In Compute the check digit mode it takes a number without its last digit and returns the digit to append. In both cases a table shows every digit, which ones are doubled and what each contributes to the sum, so you can follow or teach the method by hand.
Privacy: the calculation runs entirely in your browser. The number you type is never stored, logged or transmitted, and unlike other fields on this site it is not written into the page address. Even so, the examples here use test numbers only, and there is no reason to type a real card number into any website just to check its digits.
How to use this calculator
- Choose Validate a number or Compute the check digit.
- Type or paste the digits. Spaces, dashes and dots are removed automatically, so
7992 7398 713and79927398713are the same. - Read the result: valid or invalid (with the correct check digit), or the check digit and the completed number.
- Open the table and the steps to see each doubled digit and the sum modulo 10.
- For numbers of 12–19 digits, the first digit is described with its generic ISO/IEC 7812 industry category; the calculator does not look up any real issuer.
The formula
Number the digits from the right, the check digit being position 1. Every digit in an even position is doubled, and when the double is 10 or more, 9 is subtracted (the same as adding its two digits, e.g. ). The number is valid when the total is a multiple of 10:
To create a check digit, apply the same weights to the payload as if the check digit were already in place — so the payload's rightmost digit is doubled — and take
where is the weighted sum of the payload.
Worked example
Take the standard test number 79927398713. From the right, the digits in positions 2, 4, 6, 8 and 10 (1, 8, 3, 2, 9) are doubled to 2, 16, 6, 4, 18, which become 2, 7, 6, 4, 9 after subtracting 9 from the two-digit results. Reading left to right, the contributions are
Since 70 is a multiple of 10, the number is valid. Removing the last digit and asking for the check digit of 7992739871 gives back 3.
Swap the last two digits to get 79927398731 and the check fails; for the payload 7992739873 the check digit would have to be 9. Luhn's own patent works through 4872148, whose check digit is 4.
What the Luhn check catches — and what it does not
The algorithm was designed for human transcription errors:
- Every single-digit error is detected: changing any one digit always changes the sum by an amount that is not a multiple of 10.
- Almost every swap of two adjacent digits is detected. The single exception is , because both pairs contribute 9 to the sum.
- Some twin errors (such as ) and most larger mistakes are not guaranteed to be caught.
It is not a security feature. Anyone can produce numbers that pass, so a valid result proves only that the digits are self-consistent, never that a card, phone or account exists. Stronger schemes, such as the Verhoeff or Damm algorithms, catch every adjacent transposition.
Where you meet the Luhn formula
| Number | Length | How Luhn is used |
|---|---|---|
| Payment card number (PAN) | 12–19 digits | Last digit is the check digit (ISO/IEC 7812-1) |
| IMEI of a mobile phone | 15 digits | 14-digit identifier + Luhn check digit |
| Canadian Social Insurance Number | 9 digits | Last digit is a Luhn check digit |
| Many loyalty, gift-card and account numbers | varies | Issuer's choice |
The first digit of a card number is the major industry identifier in ISO/IEC 7812 (4 and 5 are banking and financial, for example), and the first six to eight digits form the issuer identification number. Our calculator only names the broad industry category; it never looks up an issuer.
Frequently asked questions
Is it safe to type a number here?
The check runs only in your browser; nothing is stored or sent, and the number is not added to the page URL. Still, you do not need a real card number to learn or test the algorithm — the test number 79927398713 works fine.
Why do some doubled digits have 9 subtracted?
A doubled digit can reach 18. Luhn adds the digits of the result (16 becomes 1 + 6 = 7), and subtracting 9 from any number between 10 and 18 gives exactly the same value, so it is a quicker way to write the rule.
How do I calculate a Luhn check digit?
Choose “Compute the check digit” and enter the number without its last digit. The payload’s rightmost digit is doubled, the weighted sum S is computed, and the check digit is (10 − S mod 10) mod 10.
Does a valid Luhn check mean a card is real?
No. It only shows the digits are internally consistent. Whether a card is real, active or yours is something only its issuer can confirm.
Can I check an IMEI number?
Yes. An IMEI has 15 digits, the last being a Luhn check digit computed over the first 14. Enter all 15 digits in Validate mode, or the first 14 to compute the check digit.
Sources
- ISO/IEC 7812-1:2017 — Identification cards, Identification of issuers, Part 1: Numbering system (Annex B, Luhn formula)
- H. P. Luhn, US Patent 2,950,048 “Computer for verifying numbers” (1960)
- GSMA, IMEI Allocation and Approval Process (TS.06) — IMEI check digit
Last updated: