Sales

Check Digit Calculator

Enter a number without its check digit to compute the Luhn check digit.

  • Free
  • No sign-up

Your number

Enter a number to compute its check digit.

Worked example

With these example inputs:

  • Number (without check digit)7,992,739,871

Check digit: 3

  • Luhn sum67
  • Digits processed10

Add this calculator to your site

Free to embed. Copy the snippet below, it drops the live calculator straight into any page.

On a payment card, the check digit is the last digit, calculated from all the digits before it. Type those digits and the calculator returns the Luhn check digit, which almost every card uses.

The digit is there to catch typing mistakes. Here's how it works, what it catches, and which numbers use other rules.

Double every second digit, starting from the right

The Luhn method takes four steps. Here they are on 1234567, a made-up number, worked from its right-hand end:

  1. Double every second digit, beginning with the last. So 7, 5, 3 and 1 become 14, 10, 6 and 2.
  2. If doubling gives 10 or more, add the two digits: 14 counts as 5 and 10 as 1.
  3. Add up all seven results: 5 + 6 + 1 + 4 + 6 + 2 + 2 = 26. This is the Luhn sum the calculator shows.
  4. The check digit lifts the sum to the next multiple of 10. From 26 to 30 takes 4, so the full number is 12345674.
check digit = 10 − last digit of the Luhn sum (0 when the Luhn sum already ends in 0)

Adding a doubled digit's two digits gives the same result as subtracting 9: 14 − 9 = 5. In a correct number, the Luhn sum plus the check digit always ends in 0: 26 + 4 = 30.

Testing a number you already have

This calculator works out a check digit; it doesn't grade a finished number. So leave off the last digit when you type. If the answer matches the digit you left off, the number passes.

Typing the whole number is an easy slip. The calculator then treats every digit as input and answers for a longer number.

Spaces and dashes don't matter. The calculator skips anything that isn't a digit, so "7091 553" and "7091553" give the same result. Grouping helps you proofread, too. The Baymard Institute, which studies checkout design, calls errors in a 16-digit unformatted string "needlessly difficult" to spot.

Which typing mistakes it catches, and which slip through

In a doubled spot, no two digits count the same:

digit:   0 1 2 3 4 5 6 7 8 9 doubled: 0 2 4 6 8 1 3 5 7 9

So any single wrong digit changes the last digit of the sum, and the check digit stops fitting. Here's the calculator's answer for 7091553, whose check digit is 3, and for five mistyped versions:

Digits typedCheck digitLuhn sum
7091553 (correct)327
7091558 (last digit wrong)228
7091535 (neighbors 5 and 3 swapped)020
7901553 (0 and 9 swapped)327
7051953 (9 and 5 swapped, two apart)327
7091223 (55 typed as 22)327

Any row still showing 3 is a mistake the check digit can't see. Swapping two neighbors is usually caught, because one of them moves into a doubled spot. The exception is 0 and 9: doubled, 9 still counts as 9 and 0 as 0.

Two other slips are invisible. Digits two places apart sit in the same kind of spot, so swapping them leaves the sum unchanged. And 55 typed as 22 adds 6 either way: 1 + 5 or 4 + 2.

A passing number isn't a real card

The check digit shows only that the digits agree with each other. Anyone can make a number that passes: type any digits here and the calculator supplies a last digit that fits.

So a card number that passes might belong to nobody. Whether an account exists, is open or has money in it isn't something the digits can tell you.

Weighing up a card rather than its number? The credit card calculator shows the monthly payment and interest to clear a balance. The credit utilization calculator divides your balances by your credit limits.

Cards and US health provider numbers use Luhn

Payment cards are the best-known case. According to Baymard, Luhn validation applies to all cards except some China UnionPay cards and Diners Club enRoute. The last of those is no longer active.

The US also uses it for the National Provider Identifier (NPI), the number that identifies health care providers. Under federal rules, the NPI has 10 digits, with a check digit in the 10th position.

The 2004 rule that adopted it says the check digit uses "the ISO standard Luhn check digit algorithm." But it's calculated as if the NPI began with 80840, the prefix for US health applications on ID cards.

Digits enteredCheck digitLuhn sumDigits processed
123456789 (made-up NPI, first nine digits)7439
80840 123456789 (same, with prefix)36714

The rule mentions a constant for when the prefix is left off, without giving it. The table shows it: the prefix adds 24 to the Luhn sum, 67 − 43. It always sits in the same places, so it adds 24 to any NPI.

To check an NPI here, type 80840 followed by its first nine digits. The made-up NPI above would end in 3, making 1234567893.

Not every check digit is Luhn

Other numbers follow other rules, and this calculator can't check them. Your car's vehicle identification number (VIN) is one: under federal rules, its ninth character is a check digit.

The VIN method gives each character a value and multiplies it by a weight for its position. The products are added and divided by 11, and the remainder sets the check digit. So it can be 0 to 9 or the letter X.

A Luhn tool gives a meaningless answer for a VIN; this one even drops the letters.

Sources

Frequently asked questions

How does the Luhn algorithm work?

Double every second digit, starting with the last digit you enter, and subtract 9 from results over 9. Add everything; the check digit tops the total up to the next multiple of 10. For 7992739871, the sum is 67 and the check digit 3.

How do I check if a card number is valid?

Enter every digit except the last one. If the calculator's answer equals that last digit, the number passes the Luhn check.

Does a correct check digit mean the card is real?

No. It only shows the digits are consistent with each other. Anyone can generate a passing number, so it proves nothing about an account.

Which typing mistakes can the Luhn check miss?

Swapping 09 and 90, swapping digits two places apart, and twin errors such as 55 typed as 22. Every single-digit typo is caught.

Can I use this calculator for a VIN?

No. A VIN's ninth character is a check digit found with position weights and division by 11, not with Luhn.

How do I find the check digit of an NPI?

Type 80840 followed by the NPI's first nine digits. Federal rules compute the NPI check digit as if that prefix were there.