Luhn Validator

Validate any number with the Luhn algorithm — credit and debit cards, IMEIs, and other mod-10 identifiers. Type a number and see whether it passes, which digit is the check digit and what it should be, and the full working with every doubled digit shown. You can also compute the missing check digit for a partial number, and see which card brand the prefix suggests. It's free and runs entirely in your browser; numbers are never sent anywhere.

Card prefixes (IIN ranges)

BrandStarts withLength
Visa413, 16, 19
Mastercard51–55, 2221–272016
American Express34, 3715
Discover6011, 644–649, 6516–19
JCB3528–358916–19
Diners Club300–305, 36, 3814–19

When to use it

  1. Validate test card numbers before running a payment-form test.
  2. Check an IMEI read off a phone label for typos.
  3. Generate valid test account numbers for a QA environment.
  4. Learn how the Luhn checksum works, step by step.

How to Use

  1. Type or paste the number.
  2. Read the verdict, the check digit and the brand guess.
  3. To complete a number, enter it without its last digit in the second box.

Features

  1. Pass/fail with the expected check digit
  2. Digit-by-digit working
  3. Check-digit calculator
  4. Card brand from prefix
  5. Ignores spaces and hyphens
  6. 100% client-side

FAQs

How does the Luhn algorithm work?

From the right, double every second digit and subtract 9 from anything over 9. Add up all the digits; if the total ends in 0, the number is valid.

Does passing Luhn mean a card is real?

No. It only means the digits are internally consistent. It can't tell whether the card exists, is active or has funds.

What errors does Luhn catch?

Every single-digit error and most swaps of two neighboring digits — the commonest typing mistakes.

Which numbers use Luhn?

Payment cards, IMEI phone numbers, Canadian SINs, and many loyalty and national ID numbers.

Is the number uploaded?

No. The check runs in your browser.

Technical Details

The Luhn algorithm, or mod 10, protects credit card numbers, IMEIs, Canadian social insurance numbers and many loyalty and account numbers against typing errors. Starting from the rightmost digit, every second digit is doubled, and 9 is subtracted from any result over 9; the number is valid when the sum of all digits is divisible by 10. The validator shows that working digit by digit, with doubled positions shaded and the check digit outlined, and when a number fails it states what the last digit should have been. Computing a check digit for a partial number appends a zero, runs the same sum and takes the complement. Spaces and hyphens are ignored. The card brand shown is a format-level guess from the issuer prefix — Visa from 4, Mastercard from 51–55 or 2221–2720, American Express from 34 or 37, and so on — with a note when the length is unusual for that brand. None of this says whether a card or account exists, and nothing is transmitted.

Developer Tools

Developer Tools

  • IBAN, ISBN & Barcode Validator
  • SSL Certificate Decoder
  • HAR File Viewer
  • OpenAPI & Swagger Viewer
  • Log Analyzer
  • .env File Validator
  • HTTP Headers Parser
  • Cookie Parser