1. Home
  2. Developer tools
  3. Luhn Validator

Luhn Validator

Check whether a number passes the Luhn test, or find the check digit to append, for development, testing and data cleaning.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Luhn Validator

  1. Choose the number type.
  2. Enter one number per line.
  3. Read the verdict, network and details.

Features

  • Card network and length rules for the main networks
  • IMEI structure and Type Allocation Code
  • Shows the correct check digit for a number that fails
  • Many numbers at once
  • Test card numbers as sample
  • Nothing is sent

Supported formats

Input

  • One value per line, typed or pasted

You get

  • Verdict
  • Card network
  • Check digit

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Luhn Validator is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • A valid number may belong to no account; the check only finds typing mistakes.
  • Network recognition covers the main card networks.

Guide

The Luhn check: validating card numbers, IMEIs and other identifiers

Hans Peter Luhn, an IBM engineer, patented a simple check-digit formula in 1960. Today it is built into payment card numbers, the IMEI numbers that identify mobile phones, many national identifiers and loyalty cards. Its purpose is modest: to catch the typing mistakes people make when they copy a long number, before it is sent to a server. This validator applies the formula, adds the network and length rules for cards, and can calculate the digit you need.

The algorithm

Start from the rightmost digit, which is the check digit, and move left. Double every second digit. If doubling gives a two-digit number, add its digits together, which is the same as subtracting 9. Add all the digits. If the total is divisible by 10, the number passes. To calculate a check digit for a number without one, apply the same steps to the digits with a zero placeholder and choose the final digit that brings the total to a multiple of 10.

A worked example

Press Sample to check five numbers in card mode; three are valid and two are not. 4111 1111 1111 1111 is a valid Visa test number of 16 digits with check digit 1. 5555-5555-5555-4444 is a valid Mastercard format and 3782 822463 10005 a valid American Express number of 15 digits. 4111 1111 1111 1112 differs in the last digit only: the page says it fails the Luhn check, and that the correct check digit is 1. The last, 490154203237518, passes the arithmetic, but as a card it is rejected because Visa numbers have 13, 16 or 19 digits and this has 15. Switch to the IMEI mode and the same 15 digits validate as an IMEI.

Cards, networks and lengths

The first digits identify the issuer network: 4 for Visa, 51 to 55 and 2221 to 2720 for Mastercard, 34 and 37 for American Express. Each network allows particular lengths. The page reports the network it detects from the prefix, the number of digits and the check digit, and refuses combinations that cannot exist. That catches a number which is Luhn-valid by accident.

IMEI numbers

An International Mobile Equipment Identity has 15 digits: an eight-digit type allocation code that identifies the model, a six-digit serial number and a Luhn check digit. The page shows the three parts. An IMEISV, 16 digits, replaces the check digit with a two-digit software version, so it carries no checksum to verify.

Calculating a check digit

Developers who generate test data or issue their own identifiers can enter the number without its last digit and get the digit to append. Use only test ranges for card-like numbers.

Limits

A passing number may belong to no account, and a failing one may still be a real number typed wrongly. Luhn is no protection against fraud. Please use published test numbers rather than real card numbers on any website; this page works in your browser and sends nothing.

Checked against the current version of the Luhn Validator on .

Frequently asked questions

Which errors can a Luhn check not catch?

It catches every single-digit mistake and most swaps of two adjacent digits, but not a swap of 09 and 90, and not two errors that happen to cancel. It is a typing check and not a security feature.

Why can the same digits be valid in one mode and invalid in another?

The Luhn arithmetic is the same, but a card number also has to match the length rules of its network. The 15-digit value 490154203237518 passes Luhn, and as a card it fails because Visa numbers have 13, 16 or 19 digits, while as an IMEI it is valid.

Does a valid Luhn number mean the card exists?

No. The test only catches typing mistakes. A number can pass and belong to no account.

Can I use this to find card numbers?

No, and it is not built for that. It validates a number you already have, and it is best used with test numbers rather than real ones.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.