What is the Luhn algorithm?

The Luhn algorithm, also called mod 10, is a quick check that catches typing mistakes in long numbers. The last digit is a check digit, worked out from all the others. Payment card numbers use it, and so do the IMEI numbers of phones and some national ID numbers. It catches any single wrong digit and almost every swap of two neighboring digits, the most common typos. It isn't a security feature: anyone can make up a number that passes.

Tool description

Type or paste a number and the Luhn number validator tells you at once whether it passes the check. Spaces and dashes are ignored, so you can paste a number the way it's printed, in groups. When a number fails, the tool also shows which last digit would make it pass, which helps you find the typo.

To add a check digit to a number of your own, use the Luhn checksum generator.

Features

  • Checks numbers of any length, from short codes to card and IMEI numbers
  • Ignores the spaces and dashes between groups of digits
  • Shows the check digit a failing number should end with

How it works

Start from the rightmost digit, the check digit, and double every second digit going left. When doubling gives a two digit number, add its two digits together. Then add up all the digits. The number passes when the total is a multiple of 10.

Take 1234 5674. Doubling 7, 5, 3 and 1 gives 14, 10, 6 and 2, which count as 5, 1, 6 and 2. The digits left as they are, 4, 6, 4 and 2, add up to 16, so the total is 30 and the number passes. Change the last digit to 5 and the tool says the check digit should be 4.