EthicalFusion

Credit Card Validator

Check card numbers with the Luhn algorithm and detect the card type.

Was this tool helpful?

Thanks for the feedback!

This Credit Card Validator checks whether a card number is mathematically well-formed using the Luhn checksum, then names the likely card network from its first digits. Developers use it to test checkout forms and payment integrations; shoppers can use it to catch a mistyped digit. It never contacts a bank, so it can't tell you whether a card is active or has funds.

What to enter and what you get back

Paste a number of 12 to 19 digits. Spaces and hyphens are removed automatically, so 4111 1111 1111 1111 and 4111-1111-1111-1111 are treated the same, but letters or other symbols trigger the message "Enter 12-19 digits." The result has two lines: ✓ Passes Luhn check or ✗ Fails Luhn check (invalid number), followed by a brand pattern.

The Luhn check, step by step

The Luhn algorithm (also called mod 10) was designed to catch typing mistakes. Starting from the rightmost digit, double every second digit; if a doubled value is over 9, subtract 9. Add everything up. A valid number gives a total divisible by 10.

For 4111 1111 1111 1111, the doubled positions are the first digit and every other 1 after it: 4 becomes 8, and seven 1s become 2 each, giving 8 + 14 = 22. The eight undoubled 1s add 8. The total, 30, ends in zero, so the number passes. Change the last digit to 2 and the total becomes 31, so it fails. The check catches every single wrong digit and nearly every swap of two neighbouring digits (09 and 90 is the one swap it misses).

The same checksum protects other numbers too. A 15-digit mobile IMEI such as 490154203237518 passes, because its last digit is a Luhn check digit; ignore the brand line in that case.

How the brand is guessed

Number starts withTool shows
4Visa
51 to 55Mastercard
34 or 37American Express
6Discover/RuPay
anything elseUnknown

Treat this as a hint, not an identification. Mastercard's newer 2221 to 2720 range, JCB, Diners Club, Maestro and some RuPay ranges all show Unknown, and UnionPay cards starting with 62 are labelled Discover/RuPay. The exact issuing bank can only be found from the full BIN (the first six to eight digits) through a BIN database.

Test numbers for developers

  • 4111 1111 1111 1111 (Visa format)
  • 5555 5555 5555 4444 (Mastercard format)
  • 3782 822463 10005 (American Express, 15 digits)
  • 6011 1111 1111 1117 (Discover format)

These are widely published gateway test numbers. They pass Luhn but will be declined by any live payment system, which makes them ideal for testing form validation without risk.

What passing does not prove

A number can pass Luhn and still be unissued, expired, blocked or fake; roughly one in every ten random numbers passes by chance. Expiry date, CVV, cardholder name and OTP checks all happen at the bank during authorisation. The check runs in your browser, but as a habit, use test numbers rather than your real card.

Frequently asked questions

Does passing the Luhn check mean the card is real?
No. It only means the digits are arranged correctly. Whether the card exists, is active and has funds can only be confirmed by the issuing bank during a payment.
Why does my RuPay or Mastercard show as Unknown?
The brand guess uses a few simple prefixes. Mastercard numbers starting with 2 and some RuPay ranges fall outside them, so the label is only a hint.
Is it safe to type my card number here?
The check runs locally in your browser and nothing is sent to a bank. Even so, test numbers are enough for checking a form, so there is rarely a reason to paste a real card.
Which test card numbers pass the check?
4111 1111 1111 1111 for Visa, 5555 5555 5555 4444 for Mastercard and 3782 822463 10005 for American Express all pass Luhn.
Can I use it to check an IMEI number?
Yes, for the checksum. A 15-digit IMEI ends in a Luhn check digit, so a pass means the digits are consistent. Ignore the brand line.

Related tools

People also used

Embed this tool on your site

Paste it into any blog or website. Free, with a credit link.