Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Free tool · Developer tools

Luhn checker

Paste a number and the Luhn checker tells you at once whether it passes, with the sum and a row for every digit. The sample 79927398713 adds up to 70 and passes. You can also type a number without its last digit and get the check digit that completes it.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

What do you want to do?

Digits only, with spaces or hyphens if you like. Use a test number, not a real card.

Luhn check

Passessum 70, remainder 0

  • 11 digits
  • Sum 70
  • Remainder 0
  • Format is valid
Last digit that would pass
3
Digits read
7992 7398 713
Each digit from the right
PlaceDigitDoubledValue
13no3
21yes2
37no7
48yes7
59no9
63yes6
77no7
82yes4
99no9
109yes9
117no7

How to use the Luhn Checker (Card Number Validation)

  1. Under What do you want to do? keep Check a number to test a full number, or pick Find the check digit to complete a partial one.
  2. Type or paste the digits in the number box. Spaces and hyphens are fine, and any other character gets a message that names it.
  3. Read Passes or Fails with the sum and the remainder. When a number fails, Last digit that would pass shows the one change to the final digit that fixes it.
  4. Open the table to follow each digit from the right. In the check digit mode, press Copy full number to take the finished number with you.

What is the Luhn algorithm?

The Luhn algorithm, also called the mod 10 check, is a short piece of arithmetic that decides whether a string of digits could be a correctly typed number. A scheme that ends its numbers with a Luhn check digit can reject most typing mistakes before anything is looked up. The test never contacts anyone and has no memory of any number: it only does sums on the digits you give it.

The steps are three. Start at the last digit and move left, doubling every second digit. If a doubled digit is more than 9, subtract 9 from it, which is the same as adding its two digits. Add up everything, doubled and untouched alike. The number passes when the total ends in 0. For 79927398713 the total is 70, so the remainder after dividing by 10 is 0 and the number passes.

Passing is a statement about the digits only. A number can pass and still belong to nobody, and a real number can be mistyped into another one that also passes. Treat the result as a typo filter, never as proof that an account, card or device exists.

How do I check a number with the Luhn algorithm by hand?

Write the digits in a row and number them from the right, so the last digit is place 1. Places 2, 4, 6 and so on are doubled. In 79927398713 those places hold 1, 8, 3, 2 and 9. Doubled they become 2, 16, 6, 4 and 18, and the two big ones turn into 7 and 9 after subtracting 9. The other digits stay as they are: 3, 7, 9, 7, 9 and 7.

Add the lot: 3 + 2 + 7 + 7 + 9 + 6 + 7 + 4 + 9 + 9 + 7 = 70. The sum ends in 0, so the number passes. Change the last digit to 0 and the sum becomes 67, which leaves a remainder of 7, so 79927398710 fails. The table here shows the same work for the sample number, one row per digit.

Always count from the right, not the left. The doubling pattern depends on the length of the number: counting from the left gives the wrong places for numbers of odd length, and this is the most common slip when people check by hand.

Each digit of 79927398713, counted from the right
PlaceDigitDoubledCounts as
13no3
21yes2
37no7
48yes7
59no9
63yes6
77no7
82yes4
99no9
109yes9
117no7

How do I calculate a Luhn check digit?

To complete a number, treat the digits you have as if a 0 sat at the end, then work out the sum with the doubling shifted one place to the left, which the 0 takes care of. The check digit is whatever brings the total up to the next multiple of 10: (10 minus the sum mod 10) mod 10. For 7992739871 the sum with a 0 appended is 67, the remainder is 7, and 10 minus 7 gives a check digit of 3. The full number is 79927398713, and its sum is 70.

The last digit always lands between 0 and 9, and exactly one value works for any given body, so the check digit is never a choice. The mode Find the check digit does this for you and shows the whole table on the finished number.

Check digits for a few bodies
Digits typedSum with a 0 addedCheck digitFull number
799273987167379927398713
4539578763621487464539578763621486
49015420323751528490154203237518
1234567894371234567897
000000000000000

Which mistakes does a Luhn check catch?

Change any one digit and the sum moves, so every single wrong digit is caught. Swapping two neighbouring digits is caught too, with one exception: the pair 09 and 90 swap without changing the sum.

Two mistakes in one number can cancel out, and a mistyped number can land on another valid one by chance. About one in ten random strings passes. The rows below take the sample number and swap neighbouring pairs, showing that each swap makes the sum wrong and the number fail.

Swapping neighbouring digits in 79927398713
SwapNew numberResult
79 to 9797927398713fails
92 to 2979297398713fails
39 to 9379927938713fails

Because the checker is only arithmetic, use test numbers when you try it out. Nothing you type is sent anywhere, yet there is no reason to type a live account number into any tool.

Use it with

Questions

What does it mean when a number fails the Luhn check?

Its digit sum is not a multiple of 10, so it contains a typing mistake or was never built with a Luhn check digit. 79927398710 gives a sum of 67, which ends in 7, so it fails.

Does a number that passes the Luhn check really exist?

Not necessarily. Passing only shows the digits are consistent with each other. A passing number can still belong to no account at all.

How is the Luhn check digit calculated?

Add the digits you have with a 0 at the end, doubling every second digit from the right. The check digit is 10 minus the last digit of that sum, or 0 if the sum already ends in 0. For 7992739871 it is 3.

Why do I double every second digit from the right?

The pattern has to be fixed from the check digit side so the same rule works for numbers of any length. Counting from the left gives the wrong places for numbers with an odd number of digits.

Which errors can the Luhn algorithm detect?

Every single wrong digit and every swap of two neighbouring digits except 09 and 90. It does not catch every pair of errors, and about one random string in ten passes.

Is it safe to paste a number into this checker?

The sums are done by the script on this page and the digits are not sent anywhere. A made up test number does the job just as well as a real one, so use that.

The tool's results are computed in your browser by the code on this page; the explanations are checked against the tool's own output.