· 4 min read
How to Get Test Credit Card Numbers for Testing
Heshan Fernando
Co-founder & COO
You’re building or QA-testing a checkout form and you need to verify that the card number field actually validates input correctly — rejects too-short numbers, accepts the right format for Visa versus Amex, catches an obvious typo. Typing a random 16-digit string doesn’t cut it, because most payment form validation checks the number against the Luhn algorithm before it even looks at anything else, so a genuinely random number fails validation for the wrong reason.
You also, obviously, shouldn’t be typing a real card number into a staging environment or a form you’re not sure has finished PCI-compliant handling yet. That leaves a specific, narrow need: numbers that pass the same structural checks a real card number would, formatted correctly by network, but that aren’t tied to any real account.
What Luhn-valid test numbers actually are
The Luhn algorithm is a simple checksum that most card numbers satisfy — it’s the first-pass validation nearly every payment form runs before checking anything against an actual processor. A test number generator that produces Luhn-valid numbers means your form’s basic validation logic gets exercised properly, without the number being tied to any real funding source.
Different card networks — Visa, Mastercard, Amex, Discover — use different starting digits and lengths, so a useful generator needs to produce numbers in the correct format per network, not just a generic 16-digit string.
Why people get stuck here
- Random numbers fail Luhn validation. A number typed at random almost always fails the checksum, which means you’re testing the “reject invalid input” path instead of the “accept valid input” path you actually wanted to check.
- Network format differences. Amex numbers are 15 digits and start differently than Visa’s 16-digit, 4-prefixed numbers — a generator that ignores this produces numbers that look wrong for the network you’re testing.
- Confusing test numbers with real ones. Some payment processors publish their own official test numbers for sandbox environments — those are different from a generic Luhn-valid generator and matter when you’re testing against a specific processor’s sandbox.
- Using a real card “just to see.” It’s tempting to reach for a real card when a test environment doesn’t accept fake numbers, but that risks real charges or data exposure for a task that shouldn’t need it.
Common mistakes to avoid
- Assuming any Luhn-valid number will work against a live payment processor’s sandbox — most processors require their own specific published test numbers for that.
- Testing only one card network’s format when your form is supposed to accept several.
- Forgetting that Luhn validity only checks structure, not fraud or account status — it’s for testing your form’s input handling, not a payment gateway’s fraud logic.
- Leaving test numbers in a production database seed or hardcoded in shipped code instead of generating fresh ones per test run.
How to do it with Credit Card Test Number Generator
Online Tool Store’s Credit Card Test Number Generator produces Luhn-valid, non-real numbers by network, entirely in your browser.
- Open the Credit Card Test Number Generator and pick the network you’re testing — Visa, Mastercard, Amex, or another supported network.
- Generate a number and confirm it’s formatted correctly for that network’s length and prefix.
- Use it to test your form’s client-side validation, database schema, or display formatting.
- Generate additional numbers per network if your form needs to accept multiple card types.
Frequently asked questions
Will these numbers work with a real payment processor sandbox?
Not necessarily — most payment processors (Stripe, PayPal, and others) publish their own specific sandbox test numbers, which you should use when testing against their actual API. This tool is for testing your form’s own input validation and formatting logic.
Are these real card numbers?
No — they’re generated to satisfy the Luhn checksum and match the correct format for each network, but they aren’t tied to any real account or funding source.
Why does my form reject a number that passes Luhn?
Some forms add extra validation beyond Luhn, like checking the number against a specific processor’s test-number list, or verifying the expiration date and CVV format together — check what validation layer is rejecting it.
Final thought
Test your payment form with numbers built for testing, not a real card and not a random guess — Luhn-valid, network-formatted numbers exercise the validation logic you actually need to check.