Luhn Algorithm Checker

Check whether a card number, IMEI or account number passes the Luhn (mod 10) checksum, or compute the missing check digit, with a digit-by-digit walkthrough.

Last updatedHow we build & check our tools
Results will appear here once you enter your values.

How the Luhn algorithm works

The Luhn algorithm, patented by IBM engineer Hans Peter Luhn in 1960 and now specified in ISO/IEC 7812-1, adds one check digit to the end of a number so that simple typing mistakes can be caught without contacting a server.

To validate a number: start at the rightmost digit (the check digit) and move left. Leave the check digit alone, double the next digit, leave the one after that, and keep alternating. When a doubled digit is 10 or more, subtract 9 (for example 8 doubled is 16, and 16 minus 9 is 7; that is the same as adding 1 and 6). Add everything up. The number is valid when the total is a multiple of 10.

To compute a check digit: run the same process on the payload, but double the rightmost payload digit first, because it will sit next to the check digit once appended. The check digit is (10 − (sum mod 10)) mod 10.

Worked example: for 7992739871 the weighted sum is 67, so the check digit is (10 − 7) mod 10 = 3, and the full number 79927398713 sums to 70.

Where you will meet Luhn check digits

  • Payment cards. Every Visa, Mastercard, American Express and Discover primary account number ends in a Luhn check digit. Checkout forms run the test in the browser to flag typos before the payment request is sent.
  • IMEI numbers. The 15th digit of a phone's IMEI is a Luhn check digit over the first 14.
  • National identifiers. Canadian Social Insurance Numbers, Israeli ID numbers and several other government IDs use it.
  • Loyalty and gift cards, plus some internal account numbers, for the same cheap typo detection.

Passing the Luhn test only means the digits are self-consistent. It does not mean a card exists, has funds or belongs to anyone; only the issuer can say that.

What Luhn catches and what it misses

Luhn detects every single-digit error (one digit mistyped) and almost every transposition of adjacent digits. The exception is swapping 09 and 90: both pairs contribute the same amount to the sum, so the swap goes unnoticed. It also misses the twin errors 22 to 55, 33 to 66 and 44 to 77.

It is not a security feature. Anyone can generate a Luhn-valid number in seconds, which is why test cards such as 4111 1111 1111 1111 exist. Stronger schemes, such as the Verhoeff and Damm algorithms, catch all adjacent transpositions, and cryptographic MACs are needed when you must detect deliberate tampering.

Common implementation bugs: doubling from the left instead of the right (this breaks numbers with an odd length), forgetting to strip spaces and dashes, and parsing long numbers into a 64-bit integer, which overflows beyond 19 digits. This checker works digit by digit on the string, so any length is fine.

Frequently Asked Questions

Common questions about the Luhn Algorithm Checker

No. The checksum only proves the digits are internally consistent. Test numbers like 4111 1111 1111 1111 pass Luhn but are not live cards. Only the issuing bank can confirm an account exists.
From the same team

Turn your GPU into an OpenAI-compatible API endpoint

Wide Area AI routes your LLM API calls to your own hardware over a Cloudflare Tunnel — free local inference with edge caching and automatic cloud failover. Works with any OpenAI SDK.

Start routing — free

Sources & References

Luhn algorithm

Algorithm description, the 7992739871 worked example and the list of undetected errors

ISO/IEC 7812-1:2017 Identification cards: Identification of issuers, Part 1: Numbering system

Standard that specifies the Luhn check digit for payment card numbers

US Patent 2,950,048: Computer for Verifying Numbers

Hans Peter Luhn's original 1960 patent