Credit Card Validator
The Luhn algorithm, worked by hand
Every payment card number carries its own typo detector: the last digit is a check digit chosen so the whole number passes a formula published by Hans Peter Luhn in 1960 and now standardised as ISO/IEC 7812-1. The recipe: starting from the right, move left and double every second digit (the ones in even positions counting from the right, skipping the check digit itself); if a doubled value exceeds 9, subtract 9 (equivalently, add its two digits). Add everything — doubled values, untouched digits, and the check digit. A valid number totals a multiple of 10.
On the test Visa 4242424242424242: the eight 4s sit in the doubled positions and become 8s (sum 64); the seven other 2s sum to 14; the check digit is 2. Total 64 + 14 + 2 = 80 — a multiple of 10, so the number is well-formed. Change the last digit to 1 and the total is 79: fail. Luhn catches every single-digit error and almost every transposition of neighbouring digits (the famous exception is 09 ↔ 90), which is exactly the error profile of humans copying sixteen digits. What it does not do is say the card exists, belongs to anyone, or can pay for anything — it certifies arithmetic, not money. That distinction is why this tool is safe to offer and safe to use: a Luhn-valid number is usually a test number or a coincidence, never proof of funds.
Reading the brand from the first digits
The opening digits — the Issuer Identification Number — announce the network before the checksum runs:
| Brand | Starts with | Length |
|---|---|---|
| Visa | 4 | 16 (13 and 19 exist) |
| Mastercard | 51–55, or 2221–2720 | 16 |
| American Express | 34 or 37 | 15 |
| Discover | 6011, 644–649, or 65 | 16 |
| Diners Club | 300–305, 36, or 38 | 14 |
| JCB | 35 | 16 |
The first digit alone is the Major Industry Identifier: 4 and 5 are banking and finance (Visa, Mastercard), 3 is travel and entertainment (Amex, Diners, JCB), 6 is merchandising and banking (Discover). Brand detection matters to developers because it drives the little card icon, the spacing pattern (Amex groups 4-6-5, others 4-4-4-4) and the expected length and security-code rules in a checkout form — all before a single digit is sent to a payment processor. The published test numbers exist precisely so those forms can be exercised safely: Visa 4242424242424242, Mastercard 5555555555554444, Amex 378282246310005 — all Luhn-valid, all incapable of buying anything, and all prefilled-worthy. Try each above.
A necessary word about real card numbers
Never type a real card number into a random web validator — including, as a matter of principle, this one. This page runs entirely in your browser (view source and check: the number is never transmitted, stored or logged, and the site has no server component to receive it), but the habit is what protects you: real numbers belong only in the checkout of the merchant you are paying, over HTTPS, or in your bank’s own app. A validator needs nothing real to be useful — its legitimate users are developers testing forms, support staff checking whether a customer mistyped a digit, and the curious. If a site ever asks for a real card number “to validate it”, close the tab: validation is arithmetic, and arithmetic does not need your money’s credentials.
Frequently asked questions
How does the Luhn check work?
Double every second digit counting from the right (skipping the final check digit), subtract 9 from any doubled value over 9, then add all the digits together — doubled values, untouched digits and the check digit. If the total is a multiple of 10, the number is well-formed. On Visa’s test number the doubled digits sum to 64, the rest to 16, total 80: valid. The algorithm, from 1960, is standardised as part of ISO/IEC 7812-1 and is run by every checkout form before a number is submitted.
Does a valid result mean the card is real?
No. It means the number is arithmetically well-formed — that its check digit matches its other digits. One in ten random numbers of the right length passes Luhn by chance, the card networks publish test numbers that pass deliberately, and a well-formed number may belong to a closed, expired or nonexistent account. Only the issuing bank, asked through a payment network during an actual transaction, can say a card is real and funded. Treat any tool claiming more than the checksum as a scam.
What are the standard test card numbers?
The networks publish them for developers: Visa 4242424242424242, Mastercard 5555555555554444 (and 2223003122003222 for the 2-series), American Express 378282246310005, Discover 6011111111111117, Diners Club 3056930009020004, JCB 3566002020360505. Any expiry date in the future and any CVV complete them in test environments. They pass Luhn by design and cannot be charged — payment processors recognise them in sandbox mode, and in live mode they simply decline.
Why does my card number fail even though the card works?
Almost always a transcription slip: Luhn catches every single wrong digit, so one misread 3-for-8 invalidates the whole string — which is the point of the checksum. Check the digits against the card (the embossing groups of four help), watch for a dropped or doubled digit, and make sure you have not included the card’s issue or account numbers printed elsewhere on the card. If the digits are definitely right and it still fails, the number may be a charge or debit product using a different scheme — or the card itself needs replacing; your bank can confirm.
Is it safe to enter a card number here?
This page performs the check locally in your browser — nothing is transmitted or stored, and you can verify that in the page source. Even so, the safe habit is to use test numbers only, here and everywhere: a validator never needs a real number to do its job. The prefilled 4242 number is Visa’s public test card. If you arrived here hoping to check whether a real card works, the only legitimate way is a small transaction or your bank’s app — no website can tell you.
Related tools
Behaviour verified in Node on 24 November 2026. Everything runs in your browser — nothing you type is sent anywhere.