What is a test card generator? Test data only
This tool generates test credit card numbers for developers only. The numbers it makes use well-known public test ranges — Visa numbers starting with 4242, Mastercard numbers starting with 5555, and Amex numbers starting with 3782 — and they pass the Luhn check, so they behave like real card numbers in test software. But they are test data only, not real cards: they belong to nobody, they hold no money, and they must never be used for a real purchase, a real payment, or any attempt to pay for something.
Developers need test card numbers because payment software has to be tested before it goes live. A checkout form, a billing system, or a payment gateway integration all need card numbers to test with, and using a real card for testing would charge real money. Test card numbers solve that: they pass the format checks, they trigger the test mode of a payment gateway, and they cost nothing.
This generator makes test numbers for three brands, in the right lengths — 16 digits for Visa and Mastercard, 15 for Amex — with a valid Luhn check digit, a fixed test expiry of 12/28, and a test CVC of 123. The default on this page is 3 Visa test numbers starting with 4242. Everything runs in your browser, so nothing is stored and there is no account to create. For random numbers rather than card formats, a random number generator makes those instead.
How this test card generator works — and why it is test data only
The generator starts with a public test prefix for the brand you picked: 4242 for Visa, 5555 for Mastercard, and 3782 for Amex. These prefixes are published by the payment networks and by gateways like Stripe as test ranges, and every developer in the world uses the same ones. It then fills the middle digits at random and works out the last digit with the Luhn algorithm, which is the check digit every card number carries.
The Luhn check is what makes the output pass format validation. Starting from the right, every second digit is doubled, digits over 9 have 9 subtracted, and the total must be a multiple of 10. The last digit is chosen to make that true. A card number that fails Luhn is rejected by every payment form in the world; a number that passes Luhn is accepted as a well-formed number, which is exactly what test software needs.
But passing a format check is not the same as being a real card. These numbers are random apart from the test prefix: no bank issued them, no account exists behind them, and no money can ever be charged to them. In a payment gateway's test mode they trigger a fake approval; in a real checkout they will be declined. That is why this tool is labelled test data only, and why the article says so in every section. A password generator makes test passwords the same way — random, labelled, and never used for real.
Test card numbers by brand
Each brand has its own test prefix and its own length, and getting them right is what makes the test data useful. Visa test numbers start with 4242 and are 16 digits long — the Stripe test card 4242424242424242 is the most famous test card in the world, and this generator makes numbers in that same range. Mastercard test numbers start with 5555 and are 16 digits.
Amex is the exception: its test numbers start with 3782 and are 15 digits long, not 16. That one-digit difference is a common source of test failures, because a form that expects 16 digits will reject a correct 15-digit Amex number if it is coded wrongly. Testing with a real Amex test number catches that bug before a customer does.
The expiry and CVC on this page are fixed test values, not random ones: every card shows expiry 12/28 and CVC 123. Those are the values payment test suites expect, and keeping them fixed means a test run is repeatable — the same inputs every time, with only the card number changing. The brand shown in the results box always carries the word TEST — Visa (TEST), Mastercard (TEST), Amex (TEST) — so the output is labelled at the point of use, not just in the article.
A worked example: three Visa test numbers
Here is a real run, using the defaults on this page. Brand Visa, count 3, one press of the button. The result was 4242015106660515, 4242800899504487, and 4242171878880888 — three 16-digit numbers, every one starting with 4242, every one passing the Luhn check. The count is 3, the brand is Visa (TEST), and the note says test cards only. Your run will give different middle digits, because they are random, but the count, the prefix, and the length will be the same.
Each number passes the Luhn check. Take any one, double every second digit from the right, subtract 9 from any result over 9, and add everything up — the total is a multiple of 10. That is the same check a checkout form runs, and it is the check this generator is built to pass. The first four digits are always 4242, which marks the number as a Visa test number.
Switch the brand to Amex and press again. The count is still 3, but the length is now 15, and every number starts with 3782 — one run gave 378254340346300. Switch to Mastercard and the length is back to 16, with every number starting with 5555. The brand, the prefix, and the length all change together, and the Luhn digit is recalculated each time. A JSON formatter can check the JSON file your test card numbers often end up in.
Who uses a test card generator, and why
Developers are the biggest users. A checkout form, a billing page, or a payment gateway integration must be tested with card numbers that pass validation but charge nothing. Test card numbers from a known test range are the standard way to do that, and every payment gateway documents them for exactly this purpose.
Testers are the second group. Test cases need fresh card numbers that do not belong to anyone, so a test payment can never accidentally charge a real person. A tester who uses a real card in a test risks a real charge; a tester who uses generated test numbers risks nothing, because the cards do not exist.
The third group is anyone building a demo or a training course. A trainer showing how a checkout works needs card numbers that look real but are not, and a demo that displays a real customer's card would be a serious breach. Generated test numbers solve both problems at once. The rule for all three groups is the same: test data stays in testing, and real payments use only real cards.
Test card generator vs credit card generator
This page and the credit card generator are close relatives, and the difference is scope. The credit card generator makes four brands — Visa, Mastercard, Amex, and Discover — in batches of up to 20, with no expiry or CVC shown. This page makes three brands in batches of up to 5, and it pins the test expiry to 12/28 and the test CVC to 123, so a test run is repeatable.
Use this page when a test needs the full card — number, expiry, and CVC — and when a small, repeatable batch is what the test suite expects. Use the credit card generator when a test needs Discover as well, or a bigger batch of numbers on their own. Both tools use the same public test prefixes and the same Luhn check, and both are test data only.
The other relative is the random number generator, which makes random numbers for any job. Test card numbers are random numbers with a structure: a brand prefix, a fixed length, and a Luhn check digit. If your test only needs digits, use the number generator; if it needs something that passes card validation, use this one — and keep it in testing.
Common mistakes with test card numbers
The most common mistake is using a test card number for a real purchase. Never do this. A test number is not a real card, and a real checkout will decline it. Trying to pay with numbers that are not yours is fraud, even if the numbers came from a public test range.
Second: copying test card numbers into production data. Test data belongs in test systems, and production systems must hold only real, verified data. A test card number in a production database is a data quality failure and a compliance risk. Third: assuming a passing Luhn check means a real card. Luhn proves the format is right, not that the card exists.
Fourth: sharing test numbers as if they were yours. They belong to nobody, so giving one out as your card number will at best fail and at worst look like an attempt to deceive. Fifth: testing with only one brand. Visa is 16 digits, Amex is 15, and the prefixes differ, so test with all three brands before you trust your checkout.
How to use this test card generator
Using this generator is simple. Pick a brand — Visa is the default — set how many test numbers you need, from 1 to 5, and press Generate Test Cards. The numbers appear in the results box below, separated by commas, with the count, brand, and note shown alongside them. Remember: these are test data only, not real cards.
To make another set, press the button again — every press makes a fresh set. If your test needs a different brand, change it and press again; the prefix and the length change with the brand, and the Luhn digit is recalculated each time. The test expiry is always 12/28 and the test CVC is always 123.
Everything runs in your browser. No sign-up, no account, no data sent anywhere — the test numbers never leave your device. It works offline once the page has loaded. Try it with your test suite before you need it: generate three test numbers for each brand your checkout supports, and check that your validation accepts them all.
One last tip, and it is the most important one on this page: never use these numbers for a real purchase, a real payment, or a production system. Test data stays in testing. If you need to pay for something, use your own real card.