Validate and generate numbers using the Luhn algorithm.
The Luhn algorithm (also known as the "modulus 10" or "mod 10" algorithm) is a checksum formula used to validate identification numbers such as credit card numbers (PANs), IMEI numbers, Canadian Social Insurance Numbers, and US National Provider Identifiers. Invented by Hans Peter Luhn in 1954 at IBM and patented in 1960, it is in the public domain and is described by ISO/IEC 7812-1, the international standard that governs payment card numbering. The Luhn check is designed to catch the most common human entry errors: any single-digit substitution (caught 100% of the time) and any transposition of two adjacent digits (caught in all cases except 09↔90). It is not a cryptographic hash and provides zero protection against deliberate tampering — it is purely an error-detection mechanism used as the last line of defense before a card number is sent to a payment processor. Every PAN issued by Visa, Mastercard, American Express, Discover, JCB, and UnionPay carries a Luhn-valid check digit in its rightmost position, making this calculator a daily tool for anyone developing or testing payment integrations.
Starting from the rightmost digit, every second digit moving left is doubled (subtract 9 when the double exceeds 9). Sum everything; a multiple of 10 means the number is valid:
PAN: 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Doubled: ×2 ×2 ×2 ×2 ×2 ×2 ×2 ×2 Value: 8 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 Sum = 8+1+2+1+2+1+2+1+2+1+2+1+2+1+2+1 = 30 30 mod 10 = 0 → VALID
The industry-standard test PANs published in every processor's documentation. All pass the Luhn check, none can be charged — they exist exactly so you never test with a real card:
| Test PAN | Scheme |
|---|---|
| 4111 1111 1111 1111 | Visa |
| 5555 5555 5555 4444 | Mastercard |
| 2223 0031 2200 3222 | Mastercard (2-series) |
| 3782 8224 6310 005 | American Express (15 digits) |
| 6011 1111 1111 1117 | Discover |
| 3566 0020 2036 0505 | JCB |