Luhn Algorithm Checker

: Check a credit card number, IMEI or any mod 10 number with the Luhn algorithm, work out a check digit, and see the card network, for one number or a list
Spaces, hyphens and dots between digits are ignored.
Result
Enter a number to check it with the Luhn algorithm.

The Luhn algorithm (mod 10) is the check-digit formula behind credit and debit card numbers, IMEI phone numbers, Canadian Social Insurance Numbers and many account and ID numbers. This Luhn checker tells you whether a number passes, shows the working digit by digit, works out the check digit to add to a number that has none, names the card network from the leading digits, and checks a pasted list in bulk. It works as a credit card number validator for developers and testers: the number is checked in your browser and never sent anywhere.

  1. Choose Check a number when the last digit is the check digit, or Add a check digit to work out the digit to put on the end.
  2. Type or paste the number. Spaces, hyphens and dots between digits are ignored, so 4111 1111 1111 1111 and 4111-1111-1111-1111 are the same number.
  3. Read Luhn check (Valid or Not valid) and Check digit: when the number fails, it gives the digit the last place should hold and the Corrected number. In Add a check digit mode, read Check digit and copy Number with check digit.
  4. Read Card network and Length: the network comes from the leading digits, and a length that does not fit that network is pointed out. The Luhn working table shows each digit, which ones are doubled and what each adds to the total.
  5. For many numbers, set Input to A list, one per line. The Results table gives each line's status and card network (a failing line tinted amber, a line that is not a number red), 100 rows at a time with a search box; copy the valid or corrected numbers, or download the table as CSV.

The working for Wikipedia's Luhn example 7992739871 (check digit 3), then a short list in Check a number mode: two test card numbers, one with its last digit mistyped, and an IMEI.

Input
7992739871
4111 1111 1111 1111
4111 1111 1111 1112
378282246310005
490154203237518
Output
7           → 7
9  ×2 = 18  → 9
9           → 9
2  ×2 =  4  → 4
7           → 7
3  ×2 =  6  → 6
9           → 9
8  ×2 = 16  → 7
7           → 7
1  ×2 =  2  → 2
total 67 → (10 − 7) mod 10 = 3

4111 1111 1111 1111  valid · Visa
4111 1111 1111 1112  fails Luhn (check digit 2, should be 1) · Visa
378282246310005      valid · American Express
490154203237518      valid · Visa (length does not fit)

How does the Luhn algorithm work?

From the right, keep the check digit, double every second digit after it, take 9 off any doubled value over 9, and add everything up. If the total ends in 0 the number is valid: 79927398713 totals 70, so it passes.

How do I calculate a Luhn check digit?

Choose Add a check digit and type the number without it. Starting from the rightmost digit, every second digit is doubled, the total is taken, and the check digit is what brings it up to the next multiple of 10: 7992739871 totals 67, so its check digit is 3.

Is this credit card validator safe to use with a real card number?

The number is checked by code running in your browser; it is not sent, stored or logged anywhere. Even so, there is no need to type a real card: the Luhn check works the same on the published test numbers such as 4111 1111 1111 1111 (Visa) and 5555 5555 5555 4444 (Mastercard).

Do all credit cards use the Luhn algorithm?

Almost all: Visa, Mastercard, American Express, Discover, JCB, Diners Club, Maestro, Mir and RuPay numbers end in a Luhn check digit, and so do most UnionPay cards. Gift and store cards outside these schemes may use no check digit at all.

Can I check an IMEI number with the Luhn algorithm?

Yes. A 15-digit IMEI ends in a Luhn check digit, so Check a number confirms it was typed correctly, and Add a check digit gives the 15th digit from the first 14. It says nothing about whether a phone is blocked or reported stolen.

Runs entirely in your browser. Nothing is uploaded.