Credit Card Validator

Check whether a card number passes the Luhn checksum and matches a known format, for form validation and testing. No signup. A format check only, not a payment check.

Remove Ads
Remove Ads

Result

Valid (Luhn check)
Card type

This checks the number format only (Luhn algorithm + type by prefix). It does not check whether a card is real, active, or has funds.

Remove Ads

Share on Social Media:

A credit card validator checks whether a card number is well formed — free, with no account. It runs the Luhn checksum and matches the number's length and starting digits against known card formats, so you can catch mistyped numbers in a payment form before submission. It runs entirely in your browser, so nothing is uploaded or stored. Understand the limit first: passing this check means only that the number is well formed. It does not mean the card is real, active, or has funds — only payment networks and banks can verify that. Always test with the official test numbers in the examples below, never with real card details.

On this page

  1. How to Validate a Card Number Format Step by Step
  2. What the Luhn Algorithm Is and What It Checks
  3. Format Validation Versus Real Verification
  4. Who Uses a Card Number Validator
  5. Pro Tips for Card Form Validation
  6. Common Card Validation Mistakes to Avoid
  7. Related Tools You May Need Next
  8. Frequently Asked Questions

How to Validate a Card Number Format Step by Step

  1. Enter the card number. Type the card number you want to check into the input. This is typically for testing a form, using test numbers rather than real card details. Spaces and dashes are fine — the tool strips everything that is not a digit before checking.
  2. Click Validate. The tool applies the Luhn algorithm, a checksum formula, to determine whether the number is internally consistent according to that standard, and checks the number's length and leading digits against known card formats. Typing alone does nothing — you must click the button.
  3. Read the result. Two fields appear: whether the number passes the checksum (Yes — passes Luhn check or No — fails Luhn check), and the card type (Visa, Mastercard, American Express, Discover, Diners Club, JCB, or Unknown). Each field has its own Copy button.
  4. Use it in development. Apply this format validation in building and testing payment forms, catching mistyped numbers before submission, using test numbers during development.

Illustration of a credit card being checked for validity with a security shield

What the Luhn Algorithm Is and What It Checks

Credit card numbers are not random; they follow a defined structure that includes a built-in check. The most important part of this is the Luhn algorithm, a simple checksum formula devised decades ago and used across the payment industry. It works by doubling every second digit from the right — subtracting 9 when a doubled digit exceeds 9 — adding all the digits together, and checking that the total is divisible by 10. A valid, well-formed number produces a total that satisfies the formula.

When someone mistypes a card number, transposing two digits or getting one wrong, the result usually fails the Luhn check, because the checksum no longer works out. This makes the Luhn check a valuable first line of validation in a payment form: it catches obvious errors before the number is ever submitted for processing, improving the user experience and reducing failed transactions from simple typos.

Beyond the checksum, card numbers have recognisable format patterns — particular lengths and leading digit ranges associated with different card networks. This tool checks those too, with the exact patterns below. Together, the Luhn check and the format pattern check tell you whether a number is well formed, that is, structurally plausible as a card number, which is exactly what form validation needs to catch input errors.

Card typeStarts withLength
Visa413 or 16 digits
Mastercard51–55, or 2221–272016 digits
American Express34 or 3715 digits
Discover6011 or 6516 digits
Diners Club300–305, 36 or 3814 digits
JCB2131, 1800 or 3516 digits
UnknownAnything else12–19 digits (the tool's length gate)

The two checks are independent. A number can be recognised as Visa yet fail the Luhn check, and a number can pass the Luhn check yet be Unknown — both cases appear in the worked examples below. And it is essential to understand what this validation does and does not mean. Passing the Luhn check and matching a format confirms only that a number is well formed; it says nothing about whether the number belongs to a real, active card with funds available. Only the payment networks and banks can verify that, through secure processing. So a format validator is a development and testing tool for catching input errors, entirely different from actually verifying or charging a card.

Worked examples — all public gateway test numbers, labelled as test numbers that cannot be charged:

Test numberLuhn checkCard type
4111 1111 1111 1111Yes — passes Luhn checkVisa
4242 4242 4242 4242Yes — passes Luhn checkVisa
5555 5555 5555 4444Yes — passes Luhn checkMastercard
378282246310005Yes — passes Luhn checkAmerican Express
6011111111111117Yes — passes Luhn checkDiscover
30569309025904Yes — passes Luhn checkDiners Club
3530111333300000Yes — passes Luhn checkJCB
4222222222222 (13 digits)Yes — passes Luhn checkVisa
4111 1111 1111 1112 (one digit changed)No — fails Luhn checkVisa
378282246310006 (one digit changed)No — fails Luhn checkAmerican Express
123456789012No — fails Luhn checkUnknown
6759649826438453Yes — passes Luhn checkUnknown

Format Validation Versus Real Verification

AspectFormat validationReal verification
ChecksLuhn checksum and format patternWhether the card is real and active
Done byThis tool, in the browserPayment networks and banks
Tells youThe number is well formedThe card can be charged
UseCatching input errors in formsProcessing a payment securely

Format validation is a development aid, not a licence to handle real card details. It catches input errors; it does not verify cards. A number that passes is not obviously mistyped — nothing more. Whether a card actually exists, is active, or has funds is entirely separate from whether its number is correctly formatted, which is all this tool checks.

Who Uses a Card Number Validator

Developers building payment forms. A developer uses format validation to catch mistyped card numbers in their form before submission, improving the user experience with instant feedback.

People testing checkout flows. Someone testing a checkout uses standard test numbers that pass the Luhn check to verify their form handles well-formed input correctly during development.

Front-end engineers. An engineer implementing client-side validation applies the Luhn check so obvious input errors are caught immediately, before the payment is processed.

QA testers. A tester checking a payment form verifies that it correctly accepts well-formed test numbers and rejects malformed ones, using format validation.

Students learning the Luhn algorithm. Someone studying checksums and the Luhn algorithm uses the validator to understand how the formula catches errors in identification numbers.

Laptop showing a credit card validation result with checkmarks

Pro Tips for Card Form Validation

Use it only for format validation. This tool checks whether a number is well formed via the Luhn checksum and format pattern. Use it for catching input errors in forms and testing, not as any kind of real card verification, which only banks can do.

Use official test numbers for testing. Payment providers publish standard test card numbers that pass format validation for use in development — the ones in the worked examples above, such as 4242 4242 4242 4242 for Visa and 5555 5555 5555 4444 for Mastercard. Use these test numbers, never real card details, when building and testing your payment forms.

Add the Luhn check to your forms. Implementing the Luhn check in your payment form catches many mistyped numbers instantly, before submission. This client-side validation improves the experience and reduces failed transactions from simple typos.

Never handle real card data insecurely. Real card details must be handled through secure, compliant payment processing. Never collect, store or transmit real card numbers insecurely; use a proper payment provider that handles card data safely and compliantly.

Combine format and format-pattern checks. Checking both the Luhn checksum and the length and leading-digit pattern gives more thorough format validation, catching more kinds of malformed input in your forms — including numbers that pass Luhn but match no known brand.

Understand the limits of the check. Remember that passing validation means only that a number is well formed. It does not mean the card is real or usable, so never treat a passed format check as verification that a payment will succeed.

Common Card Validation Mistakes to Avoid

Thinking format validation verifies a card. Passing the Luhn check and matching a format means only that a number is well formed, not that it belongs to a real, active card with funds. Treating format validation as real verification is a fundamental misunderstanding; only banks and networks can verify a card.

Using real card numbers for testing. Testing a form with real card details is unnecessary and risky. Payment providers publish standard test numbers that pass format validation for exactly this purpose. Always use official test numbers, never real card data, when developing and testing payment forms.

Handling real card data insecurely. Collecting, storing or transmitting real card numbers without secure, compliant processing is a serious mistake with legal and security consequences. Real card data must go through a proper payment provider.

Relying on format validation for security. Client-side format validation improves the user experience by catching typos, but it is not a security measure and does not verify or protect anything about a payment. Never rely on it as security; genuine payment security comes from secure processing by compliant payment providers, not from a format check.

Assuming a recognised type means the card is real. Type and Luhn are independent: 4111 1111 1111 1112 is recognised as Visa yet fails the Luhn check, and 6759649826438453 passes Luhn yet matches no known brand. Neither result says anything about whether a card exists.

Assuming typing alone validates. Nothing happens when you type the number — the result appears only after you click Validate. If no result shows, you have not clicked the button yet.

Clicking Validate with an empty box or a number outside 12–19 digits. The tool shows an "Enter a 12–19 digit card number" notice — it may appear twice — and leaves any previous result unchanged. With an empty box, the browser also shows a "Please fill out this field." bubble. Enter a 12–19 digit test number first.

Related Tools You May Need Next

Credit Card Generator. Generate fake, Luhn-valid test card numbers that cannot pay for anything.

Random String Generator. Generate random strings for testing and development.

Base Converter. Convert numbers between binary, octal, decimal and hexadecimal.

3D illustration of a credit card passing through a validation check

Frequently Asked Questions

How does credit card number validation work?

It works by applying the Luhn algorithm, a checksum formula, to the digits of the number to determine whether it is internally consistent, and by checking whether the number's length and leading digits match a recognised format pattern. If the number passes the Luhn check and matches a known format, it is well formed. This is used in payment forms to catch mistyped numbers before submission. Importantly, it only checks the number's format, not whether the card is real or active.

What is the Luhn algorithm?

The Luhn algorithm is a simple checksum formula, devised decades ago and used across the payment industry, that validates identification numbers like card numbers. It doubles every second digit from the right (subtracting 9 when a doubled digit exceeds 9), adds all the digits, and checks that the total is divisible by 10. When a number is mistyped, the result usually fails the check, so the Luhn algorithm catches many typing errors instantly. It is a format check for internal consistency, not a way to verify that a card is genuine or usable.

Does passing validation mean the card is real?

No, absolutely not. Passing the Luhn check and matching a format confirms only that a number is well formed, meaning structurally plausible as a card number. It says nothing about whether the number belongs to a real, active card with funds available. Only the payment networks and banks can verify that, through secure processing. So a format validator tells you a number is not obviously mistyped, but it cannot tell you whether a card actually exists, is active, or can be charged.

Which card types does it detect?

Six: Visa (starts with 4, 13 or 16 digits), Mastercard (starts 51–55 or 2221–2720, 16 digits), American Express (starts 34 or 37, 15 digits), Discover (starts 6011 or 65, 16 digits), Diners Club (starts 300–305, 36 or 38, 14 digits) and JCB (starts 2131, 1800 or 35, 16 digits). Anything else shows as Unknown — including numbers that pass the Luhn check.

What test card numbers should I use for development?

Use the standard test card numbers that payment providers publish specifically for development and testing: 4242 4242 4242 4242 (Visa), 5555 5555 5555 4444 (Mastercard), 378282246310005 (American Express), 6011111111111117 (Discover), 30569309025904 (Diners Club) and 3530111333300000 (JCB). These numbers pass format validation, including the Luhn check, so you can test that your form correctly handles well-formed input, but they are not real cards and cannot be charged.

Is it safe to enter card numbers into this tool?

This tool performs format validation in your browser and is intended for use with test card numbers during development, not real card details. The check runs entirely in your browser, so the number is never uploaded — but as a general principle, you should never enter real card numbers into tools or forms that are not secure, compliant payment systems. For testing, always use the official test numbers that payment providers supply.

Can this tool tell me if a card has money on it?

No, it cannot. This tool only checks whether a card number is well formed, by applying the Luhn checksum and checking the format pattern. It has no ability to determine whether a card exists, is active, or has any funds available, because that information is held securely by banks and payment networks and can only be checked through secure payment processing. Whether a card has funds is entirely separate from whether its number is correctly formatted, which is all this tool checks.

Why does my card show Unknown but still pass the Luhn check?

Because type detection and the Luhn check are independent. The Luhn check only tests the digits' internal consistency, while the type comes from the number's starting digits and length. A number from no recognised brand — such as 6759649826438453 — can satisfy the checksum perfectly and still show Unknown, because its prefix matches none of the six known patterns.

Why does a Visa card fail the check?

Because its digits fail the Luhn checksum. Type detection only looks at the starting digit and length, so 4111 1111 1111 1112 is recognised as Visa — but changing the last digit breaks the checksum, so it fails. A single mistyped or transposed digit is usually enough to fail Luhn, which is exactly what the check is for.

Is the credit card validator free?

Yes, it is completely free with no account and no usage limit. You can check the format of as many card numbers as you like, as often as you like, at no cost, though it is intended for use with test numbers during development, not real card details. It runs entirely in your browser on any device — click Validate and the format result appears.