Luhn Validator (Card Number Checksum)
The Luhn algorithm is a checksum formula that confirms whether a number such as a credit card number was typed correctly. The validator below applies that formula to any number you enter, entirely in your browser, and tells you whether it passes or fails along with the likely card brand. A pass means the digits are internally consistent, not that the card is real.
What the Luhn Algorithm Is
The Luhn algorithm, also called the mod 10 algorithm, is a checksum formula that detects accidental errors in a string of digits. It was published in 1960 and is now used to validate credit card numbers, debit card numbers, IMEI device identifiers, and many national identification numbers. The last digit of these numbers is a check digit, chosen so that the whole sequence passes the formula. When a digit is mistyped, the total no longer divides evenly by 10 and the number fails the check.
How to Use It
- Type or paste the number into the field. Spaces and dashes are ignored, so you can enter it in groups.
- Read the verdict. PASS means the number satisfies the Luhn checksum; FAIL means at least one digit is off.
- Check the details below the verdict: digit count, detected card brand, the check digit, and the checksum total.
- Use the result to catch a typo before you submit a form, not to judge whether a card is genuine.
How the Luhn Check Works, Step by Step
For example, the rightmost digit is left alone, the next digit to its left is doubled, the next is left alone, and so on. The check digit at the end exists only to make the final total land on a multiple of 10. This is why changing any single digit almost always breaks the result, which is exactly the property that makes the algorithm useful for catching mistakes.
What It Catches and What It Does Not
| Situation | Does the Luhn check catch it? |
|---|---|
| A single mistyped digit | Yes, almost always |
| Two adjacent digits swapped | Yes, in most cases |
| Wrong number of digits | Often, because the total shifts |
| Whether the card account exists | No |
| Whether the card is active or funded | No |
| Whether the expiry date or name match | No |
The Luhn check is a typo filter, nothing more. It lets a form reject an obviously wrong number on the spot instead of sending it to a payment processor. Only the card issuer, through its own systems, can confirm that a number maps to a real account with available funds.
Card Brand Prefixes
Card numbers begin with an issuer identification number that signals the network. The validator uses these ranges to label the likely brand: Visa numbers start with 4; Mastercard numbers start with 51 through 55, or fall in the 2221 through 2720 range; American Express numbers start with 34 or 37 and are 15 digits long; Discover numbers start with 6011 or 65. The brand label is informational and does not affect the Luhn result, which depends only on the digits and the checksum.
Privacy and Ethics
When to Use It
Developers use a Luhn validator to add front-end form validation, so a checkout page can flag a mistyped card number before submitting it. Testers use it to generate and confirm test numbers during development. Anyone building or debugging a form that accepts card numbers, account numbers, or IMEI codes can use the check to confirm their validation logic matches the standard. It is a building block, used alongside the real authorization step that the payment provider performs.
Last Thoughts on the Luhn Check
The Luhn algorithm solves one narrow problem well: it stops most typos in a card or account number from traveling any further. It does this with arithmetic alone, no lookup and no network, which is why it can run instantly in a browser. The boundary to remember is that a pass confirms consistent digits, not a real account.
Validate a test number above, then keep the limits in mind: the check is a filter, not an authorization. For related developer utilities, try our UUID validator, regex tester, and hex calculator, or browse the rest of our free online tools.
Key Takeaways:
- The Luhn algorithm is a mod 10 checksum that detects accidental typos in card and account numbers.
- It doubles every second digit from the right, subtracts 9 from any result above 9, sums all digits, and passes when the total divides by 10.
- A pass means the digits are internally consistent; it does not mean the card is real, active, or funded.
- The check catches single-digit errors and most transposed pairs, but cannot confirm an account exists.
- This validator runs in your browser and sends nothing anywhere; still, use only published test numbers.
- Card brands are detected from the opening digits: Visa 4, Mastercard 51 to 55 or 2221 to 2720, Amex 34 or 37, Discover 6011 or 65.
Frequently Asked Questions (FAQs)
Does a Luhn pass mean the card is real?
No. A pass only means the digits are internally consistent with the Luhn checksum. It says nothing about whether the number belongs to a real account, whether that account is active, or whether it has funds. Only the card issuer can confirm those things during authorization.
What numbers should I enter in this validator?
Use only published test card numbers, such as those payment processors provide for development. Do not paste a real card number into any web form for casual checking. This tool runs in your browser and sends nothing anywhere, but using test numbers is the safe and correct habit.
How does the Luhn algorithm work?
Starting from the rightmost digit and moving left, it doubles every second digit. If a doubled value is greater than 9, it subtracts 9. It adds all the resulting digits together, and the number is valid when that total is divisible by 10. The final digit of the number is a check digit chosen to make this work out.
What errors does the Luhn check catch?
It reliably catches any single mistyped digit and most cases where two adjacent digits are swapped. These are the most common human entry errors, which is why the check is used at the point of entry on forms. It does not catch every possible transposition, but it filters the vast majority of accidental mistakes.
Why does this tool also show a card brand?
The opening digits of a card number identify the network, so the tool labels the likely brand for convenience: Visa, Mastercard, American Express, or Discover. The brand is informational only. The Luhn result depends solely on the digits and the checksum, not on the detected brand.
Is my input sent to a server?
No. The entire check runs locally in your browser using plain arithmetic, with no network request. Whatever you type stays on your device. You can confirm this by disconnecting from the internet and watching the validator still work.


