Skip to content

Luhn Algorithm Calculator: Validate a Number or Find Its Check Digit

Validate a number with the Luhn (mod 10) checksum or compute its check digit, with every doubling step shown.

Your details

Task

Spaces, dashes and dots are ignored. Nothing you type leaves your browser.

Results update as you type

Result

Valid: passes the Luhn check

Correct check digit for these digits
3
Luhn sum
70
Number of digits
11

Computed in your browser only: the number is not stored, logged or sent anywhere, and it is never added to the page address.

Step-by-step solution
  1. Digits only: 79927398713
  2. Starting from the rightmost digit (position 1), double every second digit (positions 2, 4, 6…); if a double is greater than 9, subtract 9.
  3. Sum = 7 + 9 + 9 + 4 + 7 + 6 + 9 + 7 + 7 + 2 + 3 = 70
  4. 70 mod 10 = 0
  5. The remainder is 0, so the number is valid.

Luhn weighting, digit by digit

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

  1. Choose Validate a number or Compute the check digit.
  2. Type or paste the digits. Spaces, dashes and dots are removed automatically, so 7992 7398 713 and 79927398713 are the same.
  3. Read the result: valid or invalid (with the correct check digit), or the check digit and the completed number.
  4. Open the table and the steps to see each doubled digit and the sum modulo 10.
  5. 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. 16→1+6=716 \to 1 + 6 = 7). The number is valid when the total is a multiple of 10:

∑i odddi+∑i even(2di−9 [2di>9])≡0(mod10)\sum_{i\ \text{odd}} d_i + \sum_{i\ \text{even}} \big(2d_i - 9\,[2d_i > 9]\big) \equiv 0 \pmod{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

c=(10−(S mod 10)) mod 10c = \big(10 - (S \bmod 10)\big) \bmod 10

where SS 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

7+9+9+4+7+6+9+7+7+2+3=707 + 9 + 9 + 4 + 7 + 6 + 9 + 7 + 7 + 2 + 3 = 70

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 09↔9009 \leftrightarrow 90, because both pairs contribute 9 to the sum.
  • Some twin errors (such as 22↔5522 \leftrightarrow 55) 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

Last updated:

More Other calculators

People also use