DevTools Pro · All tools · About

Credit Card Number Validator

About the Credit Card Validator

This credit card number validator is a developer tool: it runs the Luhn checksum, checks the length and detects the card network from the prefix, so you can test the card inputs of a checkout form. It checks the format of a number only and cannot check whether a card exists, is active or has funds. It runs entirely in your browser, so nothing you type is stored or sent anywhere.

What this tool checks, and what no website can check

It checks: the Luhn checksum (mod 10) of the number; the length, against the lengths the detected card network uses; the card network, from the number's prefix. Two optional format checks: the expiry date is written MM/YY and is not in the past, and the security code has 3 or 4 digits for the network.

It cannot check: whether a card exists, is active or has funds; whether a security code or expiry date matches what the bank has on file; who owns the card, or whether it was stolen. No website can check whether a card is "live" without the bank; tools claiming to are scams or fraud tools.

How the Luhn algorithm works

The Luhn (mod 10) checksum catches most typing mistakes, such as a single wrong digit or two swapped neighbors. Starting from the rightmost digit, double every second digit; if doubling gives a number above 9, subtract 9. Add everything up, and the number is valid when the total is a multiple of 10.

Take the common test number 4111 1111 1111 1111. The eight doubled digits are the leading 4 (giving 8) and seven 1s (giving 14), and the eight undoubled 1s add 8. The total is 30, which ends in 0, so the checksum passes. Change the last digit to 2 and it fails. The section under the tool shows every step, plus the algorithm in JavaScript and Python.

Card network prefixes and lengths

The first digits of a card number (the IIN or BIN) identify the network, and the network decides which lengths are allowed. The prefix table under the tool lists the ranges that were checked against a published source, with the date they were checked.

A number that passes Luhn but has the wrong length for its network is still reported as invalid by this tool.

What a "valid" result does and does not mean

A pass only means the number is structurally correct. It does not mean the card exists, is active, belongs to anyone or has funds. Only the card issuer can confirm that, through a payment processor.

For development, use the sandbox test numbers your payment provider publishes. They pass these checks but are never charged. Links to the Stripe, Razorpay and PayPal test card pages are under the tool.

How to Use the Credit Card Validator

  1. Type or paste a number into Card number. Spaces and dashes are ignored and the digits are grouped automatically for the detected network.
  2. Optionally enter an expiry (MM/YY) or a security code to try the two format checks.
  3. Read the Result panel: the overall verdict, then individual checks for network, length, Luhn checksum, expiry and security code format.
  4. Click one of the Published test numbers buttons to load a known example, for instance a Visa test number or one with a deliberately bad checksum.
  5. Click Clear to empty all three fields.

Frequently Asked Questions

What is the Luhn algorithm?
The Luhn algorithm (mod 10) is a checksum that the last digit of a card number is built to satisfy. From the right, double every second digit, subtract 9 from any result above 9, add all the digits and check that the total is a multiple of 10. It catches most typos, but it is not a security feature: anyone can compute a number that passes it.
Why does a valid-looking number get declined?
Passing the Luhn check only means the number is well-formed. A payment can still be declined because the card does not exist, is blocked or expired, has no funds, or the security code or address does not match. Only the issuing bank can tell, which is why a number that passes here can still fail at a payment processor.
Which test card should I use for Stripe?
Stripe documents 4242 4242 4242 4242 as a Visa test number that always succeeds, with any future expiry date and any 3-digit CVC, when you use test API keys. Stripe lists more numbers for other networks and for simulating declines on its testing page, which is linked under the tool.
Is the card number I enter sent anywhere?
No. The checks run in your browser with plain JavaScript; the number is not stored, logged or put in the page address, and no analytics event includes it. Even so, use sandbox test numbers rather than real cards.

Related tools