Toolstia / Luhn algorithm validator
Luhn algorithm validator
Check whether a number passes the Luhn test, the checksum used by payment cards and many ID numbers, or enter all digits but the last to find the check digit that completes it. The card network is shown from the number prefix.
The Luhn check catches typing mistakes only. A number that passes is not necessarily a real account. Use test numbers when you try this out.
How it works
- Choose check or generate.
- Enter the number. Spaces and dashes are ignored.
- Read the result and the correct last digit.
How the check works
Starting from the right, every second digit is doubled. Digits above 9 have 9 subtracted. If the total is a multiple of 10 the number is valid.
What it catches
It finds any single wrong digit and most swaps of neighbouring digits. It does not prove an account exists.
Where it is used
Payment card numbers, IMEI numbers, and several national ID and customer number schemes.
Use test numbers
Documented test numbers such as 4111 1111 1111 1111 are ideal for trying the tool and for developing payment forms.
Questions
Is it safe to type a card number?
The number never leaves your browser, but for your own safety use test numbers rather than a real card. Everything happens in your browser, and nothing you enter is sent anywhere.
Does a valid result mean the card works?
No. It only means the digits are consistent. The bank decides whether a card is real.
Why does my IMEI check differ?
IMEI uses the same algorithm over 15 digits. Enter all 15 digits to check it.