Skip to content

Luhn Algorithm Calculator

Check a credit card number, SIN or IMEI with the Luhn mod 10 algorithm, or work out its check digit, with every doubling step. Nothing leaves your browser.

Calculator Details

Luhn check:ValidSee results ↓

Check a full number, or work out the check digit to add to the end

Digits only; spaces and dashes are ignored. It stays in your browser: it is not put in the page address or sent anywhere.

Your Results

Luhn check: Valid

Luhn check

Valid

Total 70 is a multiple of 10

Looks like

Unknown type

Digits

11

Correct check digit

3

Matches the last digit

The number ending 8713 passes the Luhn check: the total is 70, a multiple of 10.

Detailed Breakdown

Luhn steps, digit by digit (left to right)
PositionDigitStepAdds
17Kept7
29Doubled: 9 × 2 = 18, − 9 = 99
39Kept9
42Doubled: 2 × 2 = 44
57Kept7
63Doubled: 3 × 2 = 66
79Kept9
88Doubled: 8 × 2 = 16, − 9 = 77
97Kept7
101Doubled: 1 × 2 = 22
113Kept3

Total = 70. Doubled digits are highlighted and marked "Doubled".

How This Calculator Works

How it's calculated

from the right, double every second digit (not the check digit)

if a doubled digit is over 9, subtract 9; add all the digits

valid when total mod 10 = 0

Your numbers: 11 digits, total 70. 70 mod 10 = 0: the number passes. Everything runs in your browser; the number is not stored or sent.

Frequently Asked Questions

How does the Luhn algorithm work?

Starting from the rightmost digit, double every second digit. If doubling gives more than 9, subtract 9 (the same as adding its two digits). Add up all the digits. If the total is a multiple of 10, the number passes. For 79927398713 the total is 70, so it is valid.

How do I calculate a Luhn check digit?

Take the number without its check digit and double every second digit starting from the rightmost one, subtract 9 where needed and add up. The check digit is whatever brings the total to the next multiple of 10: (10 − total mod 10) mod 10. For 7992739871 the total is 67, so the check digit is 3.

Does a valid Luhn check mean a credit card is real?

No. The check only catches typing mistakes. Billions of numbers pass it, and a passing number may never have been issued, may be cancelled, or may belong to someone else. Only the card issuer, through a payment authorisation, can say whether a card is real and usable.

Which errors does the Luhn check catch?

Every single wrong digit, and almost every swap of two neighbouring digits. The one swap it misses is 09 ↔ 90, because 0 and 9 both contribute the same after doubling. It doesn’t catch most double errors (two wrong digits), which is why it is a typo check, not security.

Do Canadian SINs use the Luhn check?

Yes. A Social Insurance Number has 9 digits and the last is a Luhn check digit. A SIN that starts with 9 is issued to a temporary resident and expires with the permit. Never enter a real SIN on a website you don’t trust; on this page it stays in your browser and is not put in the address or sent anywhere.

How can I tell the card brand from the number?

From the first digits, the issuer identification number. Visa numbers start with 4; Mastercard with 51–55 or 2221–2720; American Express with 34 or 37 and have 15 digits. Canadian debit cards are usually co-badged Visa Debit or Debit Mastercard. The brand shown is a guess from the prefix and length.

What is an IMEI and how is it checked?

The 15-digit identity of a mobile phone, shown by dialling *#06#. The first 14 digits identify the model and unit, and the 15th is a Luhn check digit. A passing IMEI isn’t necessarily genuine or unblocked: carriers check those against their own databases.

Is it safe to type a card number here?

The check runs entirely in your browser. The number is not put in the page address, the share link or the browser history, and it is not sent to our servers. Still, there is no need to use a real card number: the examples and test numbers work just as well for learning how the check works.

The Luhn mod 10 check of ISO/IEC 7812-1 Annex B, run in your browser. The number you type is never put in the page address or share link (only the mode is) and is not sent to our servers; the API accepts it only in a POST body. Card brands are guessed from published prefix ranges and lengths, which change over time; SIN and IMEI labels come from the length and first digit only. Not included: other check-digit schemes (Verhoeff, ISBN, IBAN mod 97), card expiry or security codes, scenario compare (so no number is stored), and any check that a number is real or active.

Luhn Algorithm Calculator: Check Digits for Cards, SINs and IMEIs

By FindMySum · Last reviewed

A Luhn algorithm calculator checks whether a number passes the mod 10 test used by credit and debit cards, Canadian Social Insurance Numbers and phone IMEIs, or works out the check digit to add to the end of a number. The Luhn check is a simple way to catch typing mistakes: change any one digit, or swap two neighbouring digits, and the check almost always fails. This page shows every doubling step, guesses the type of number from its length and prefix, and runs entirely in your browser: the number you type is never put in the page address or share link and is not sent anywhere. The worked example uses the default, the textbook number 79927398713.

The algorithm step by step

To check 79927398713, work from the rightmost digit (the check digit, 3) to the left:

  1. Keep the rightmost digit as it is, then double every second digit: the 1, 8, 3, 2 and 9 (counting from the right).
  2. If a doubled digit is more than 9, subtract 9. 8 × 2 = 16 → 7; 9 × 2 = 18 → 9. Subtracting 9 is the same as adding the two digits of the result (1 + 6 = 7).
  3. Add everything up. The kept digits 3, 7, 9, 7, 9, 7 and the doubled-and-reduced digits 2, 7, 6, 4, 9 total 70.
  4. Check the total. 70 is a multiple of 10, so the number is valid.

The steps table on the page shows each digit, whether it was doubled, and what it adds to the total.

Computing a check digit

To create a number with a Luhn check digit, start from the number without it, 7992739871. Now the rightmost digit is the first to be doubled, because the check digit will sit to its right. The doubled-and-reduced digits plus the kept ones total 67. The check digit is whatever brings the total up to the next multiple of 10:

check digit = (10 − 67 mod 10) mod 10 = (10 − 7) mod 10 = 3

Append it to get 79927398713, which passes. The extra "mod 10" makes the check digit 0 rather than 10 when the total is already a multiple of 10.

What the check catches and misses

The Luhn check catches:

  • every single-digit error, because changing one digit always changes the total by an amount that is not a multiple of 10;
  • almost every swap of two neighbouring digits (a transposition), because one of the two is doubled and the other is not.

It misses the swap 09 ↔ 90, and most errors that change two digits at once. That is fine for its purpose: people mostly make single-digit and transposition errors when typing numbers.

What the check cannot do is tell you whether a number was ever issued. About one in ten random numbers of the right length passes. A passing card number may be fictional, cancelled or someone else's; only the issuing bank can authorise a payment.

Card numbers and brands

A payment card number (the primary account number) starts with an issuer identification number. The first digit is the major industry identifier: 4 and 5 are banking and financial, 3 travel and entertainment, 6 merchandising and banking. The brand follows from the first few digits and the length:

BrandStarts withLength
Visa413, 16 or 19
Mastercard51–55, 2221–272016
American Express34, 3715
Discover6011, 644–649, 6516–19

Mastercard added the 2221–2720 range (six-digit BINs 222100–272099) in 2017 because it was running out of 5-series numbers. Canadian bank cards are usually co-badged Visa Debit or Debit Mastercard and follow those prefixes; Interac-only cards use bank-specific ranges that this page doesn't try to name.

Social Insurance Numbers

A Canadian SIN has nine digits, and the ninth is a Luhn check digit, so the same test catches most typos on payroll and tax forms. A SIN beginning with 9 is issued to temporary residents, such as international students and temporary foreign workers, and expires with their permit. A number that passes the check is not proof that a SIN is valid or belongs to the person giving it; employers confirm identity with documents, not arithmetic.

Because a SIN is sensitive personal information, this page never adds the number to the URL, the share link or your browser history, and the calculation never leaves your device. When you share the page, only the mode (validate or check digit) is in the link.

IMEIs

Every mobile phone has a 15-digit IMEI, shown by dialling *#06#. The first eight digits are the type allocation code, which identifies the make and model, the next six are the serial number, and the fifteenth is a Luhn check digit over the first fourteen. The example 490154203237518 passes. Carriers use the IMEI to block stolen phones, which the Luhn check knows nothing about.

More questions

Who invented the Luhn algorithm?

Hans Peter Luhn, an IBM engineer, patented it in 1960 (US Patent 2,950,048, filed 1954) as a computer for verifying numbers. The patent has long expired, so anyone can use it, and it became part of the ISO/IEC 7812 standard for identification cards.

Why do online forms reject my card number before I submit?

Most checkout forms run the Luhn check in the browser and also check the length and prefix. If you mistype one digit, the form can tell immediately without contacting the bank. A rejected number almost always means a typo; a number that passes can still be declined later by the bank.

What other numbers use a check digit?

Many: Canadian SINs and business numbers, IMEIs, some loyalty and gift cards use Luhn; ISBNs and UPC barcodes use weighted sums with mod 11 or mod 10; IBANs use mod 97. Each scheme catches different kinds of typing errors.

Can I generate valid card numbers with the Luhn check?

You can make numbers that pass the check, but they are not cards: without an account at an issuer they can't be charged. Payment networks publish official test numbers, such as 4111 1111 1111 1111, for developers to use in test environments.

Is the Luhn algorithm a form of encryption?

No. It hides nothing and anyone can compute it. It is a checksum: a small piece of redundancy added to a number so that accidental errors are detected. Protecting a card number needs encryption and tokenisation, which payment systems use separately.

Sources

This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.

Spotted a wrong result or a bug? Report a problem

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy