How to check whether a card number is valid, and what valid does not mean
The short answer. 80. Run the Luhn check on Stripe's test card 4242 4242 4242 4242, doubling every second digit from the right, and the digits total 80. It ends in 0, so the number is valid. That means only well formed: about one random 16-digit number in ten passes, and no check shows a card exists or has money.
A card number checker does three things: the Luhn check on the last digit, the scheme named by the first digits, and whether the length fits that scheme. The Credit Card Validator does all three on the page, and the number is never sent anywhere. Every example below uses a number a payment gateway publishes for its test mode, never one that could be a live card.
The Luhn check, worked step by step
Write the number out: 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2.
- Start at the rightmost digit, the check digit, and leave it as it is.
- Moving left, double every second digit. Here that is every 4; each becomes 8.
- If a doubled digit is above 9, take 9 off it. None is, in this number.
- Add everything up.
| Digit | 4 | 2 | 4 | 2 | 4 | 2 | 4 | 2 | 4 | 2 | 4 | 2 | 4 | 2 | 4 | 2 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Doubled? | yes | yes | yes | yes | yes | yes | yes | yes | ||||||||
| Value | 8 | 2 | 8 | 2 | 8 | 2 | 8 | 2 | 8 | 2 | 8 | 2 | 8 | 2 | 8 | 2 |
Eight 8s and eight 2s: 64 + 16 = 80. The total ends in 0, so the number passes.
The taking-9-off rule matters with bigger digits. In the checker's other example, 79927398713, the doubled 9 becomes 18, then 9; the doubled 8 becomes 16, then 7. That total is 70, which also passes. The Luhn Algorithm Checker shows the table for any number you type.
What the check catches
| You type | The checker says |
|---|---|
| 4242 4242 4242 4242 | Passes; Visa, 16 digits; a published Stripe test card that succeeds |
| 4242 4242 4242 4241 (last digit wrong) | Fails: with these first 15 digits the last digit should be 2 |
| 4242 4242 4242 2442 (two digits swapped) | Fails: the last digit should be 4 |
| 6527 6589 0000 1005 | Passes; RuPay, 16 digits; a published Razorpay test card |
That is the job Luhn was made for: one mistyped digit, or two neighbouring digits swapped, almost always breaks it.
The scheme and the length
The first digits name the scheme, from the IIN ranges table the checker uses:
| Starts with | Scheme | Length |
|---|---|---|
| 4 | Visa | 13, 16 or 19 |
| 51 to 55, or 2221 to 2720 | Mastercard | 16 |
| 34 or 37 | American Express | 15 |
| 60, 65, 81, 82 or 508 | RuPay | 16 |
| 62 | UnionPay | 16 to 19 |
65 is listed for both Discover and RuPay, and only the issuer knows which a given number is. A Visa-looking number of 15 digits is flagged even when its Luhn digit fits.
What valid does not mean
- Not that the card exists. Exactly one of the ten possible last digits passes, so a number with random digits passes about one time in ten.
- Not that it is active or funded. Whether a card is open, blocked, expired or has money on it is known only to the bank that issued it.
- Not that it is safe to use in a test. Random digits behind a real prefix can be somebody's live card. For testing a checkout, use only the numbers a gateway publishes: Stripe test cards and Razorpay test cards list them, and they work in test mode and nowhere else.
There is no reason to type your own card into any validator: a pass tells you nothing about it that matters, and only the issuing bank can tell you more.
Questions people ask
How do I check if a credit card number is valid?
Paste it into a card validator. The Luhn check confirms the last digit fits the others: on 4242 4242 4242 4242 the total is 80, which ends in 0, so it passes. The first digits name the scheme, and the length is compared with what that scheme uses, such as 15 digits for American Express.
Does a valid card number mean the card is real?
No. The Luhn check only shows the number is well formed. About one random 16-digit number in ten passes it, because exactly one of the ten possible last digits fits. Whether a card exists, is active or has funds is known only to its issuing bank. Never test a checkout with a generated number.
How does the Luhn algorithm work?
From the rightmost digit moving left, double every second digit, and take 9 off any result above 9. Add all the digits, doubled and not. The number passes when the total ends in 0. For 79927398713 the total is 70, so it passes; change any one digit and it fails.
Which card number can I use for testing?
Only a number your payment gateway publishes for its sandbox. Stripe's standard one is 4242 4242 4242 4242, a Visa that always succeeds in test mode; Razorpay's RuPay test card is 6527 6589 0000 1005. Use any future expiry and any CVV. These numbers cannot pay for anything outside test mode.
Can I tell Visa from Mastercard by the number?
Yes, from the first digits. Visa numbers start with 4; Mastercard with 51 to 55 or 2221 to 2720; American Express with 34 or 37; RuPay with 60, 65, 81, 82 or 508. The prefix 65 is listed for both Discover and RuPay, so for those only the issuing bank can say which it is.
Sources
Checked 15 Oct 2026:
- Stripe: Test card numbers (4242 4242 4242 4242, a Visa that succeeds in test mode)
- Razorpay: Test Card Details (the RuPay test card 6527 6589 0000 1005)
- Wikipedia: Payment card number, IIN ranges (the prefixes and lengths in the scheme table)
- ISO/IEC 7812-1: the Luhn check digit.
- Every verdict and total on this page is the checker's own output, from the Test Credit Card Numbers tool's functions, for the numbers shown.
The tools for this
Related guides
- Test data that cannot reach a real person, built safe on purposeWhy fixtures use example.com, RFC 5737 IP ranges, gateway test cards and seeds, and the one gap: a random Indian phone number may belong to someone.