Skip to main content

Card Number Validator

Check any card number against the Luhn algorithm and detect its network, entirely in your browser.

Enter a card number to see validation results.

Try a test card number

Card Network Detection Rules

NetworkPrefix(es)Length
Visa413, 16, 19
Mastercard51-55, 2221-272016
Amex34, 3715
Diners Club36, 38, 300-30514-19
JCB3528-358916-19
Maestro5018, 5020, 5038, 6304, 6759, 6761-676312-19
Discover6011, 622126-622925, 644-649, 6516-19
UnionPay6216-19

Learn More

How card number validation works

Every card number carries its own integrity check. Validating the structure before a transaction is sent catches typos and formatting mistakes that would otherwise come back as an avoidable decline.

What is card number validation?

Card number validation checks that a Primary Account Number (PAN) is structurally correct: the network prefix is recognized, the length matches that network, and the Luhn checksum resolves. It confirms the number is well-formed, not that the account exists or has funds.

A card number is not a random string. The leading digits identify the issuing network, the length is fixed per network, and the final digit is a checksum calculated from every digit before it.

Because all three properties can be checked locally, a mistyped number can be caught in the checkout form itself, before it ever reaches an acquirer. That saves a round trip, avoids a decline on the customer record, and keeps authorization rates cleaner.

Structural validation is not an authorization. A number that passes every check here can still be declined for insufficient funds, a block, or an expired card, since those depend on the issuer.

How this validator checks a number

  1. Detect the card network

    The leading digits are matched against published network ranges, for example 4 for Visa, 51-55 and 2221-2720 for Mastercard, 34 and 37 for Amex.

  2. Verify the length

    Each network issues numbers of specific lengths. Amex is 15 digits, Mastercard is 16, and Visa can be 13, 16, or 19.

  3. Run the Luhn checksum

    Every second digit from the right is doubled, values above nine have nine subtracted, and the total must divide evenly by ten.

  4. Report the result

    A number is reported valid only when the network is recognized, the length matches that network, and the checksum resolves.

Common validation failures

SymptomUsual cause
Luhn check failsA single mistyped digit, or two adjacent digits transposed.
Length not validDigits missing or duplicated, often from a copy and paste that dropped a character.
Unrecognized networkA test number, a non-card number, or a regional scheme outside the ranges listed above.
Valid here, declined liveStructure is fine; the decline is an issuer decision such as funds, fraud rules, or an expired card.

FAQs

Turn avoidable declines into approvals

Catching malformed numbers is one small piece. SmartRetry recovers the failed payments that still slip through, automatically and without changing your payment provider.