Credit Card Generator

Test cards generated—
Length (digits)—
Brand—

How Credit Card Generator is calculated: TEST DATA ONLY — not real cards. Test card = public test prefix (Visa 4242, Mastercard 555555, Amex 378282, Discover 601111) + random digits + Luhn check digit.

What is a credit 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 555555, Amex numbers starting with 378282, and Discover numbers starting with 601111 — 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 four brands, in the right lengths — 16 digits for Visa, Mastercard, and Discover, and 15 for Amex — with a valid Luhn check digit. The default on this page is 5 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, 555555 for Mastercard, 378282 for Amex, and 601111 for Discover. 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 555555 and are 16 digits. Discover test numbers start with 601111 and are 16 digits.

Amex is the exception: its test numbers start with 378282 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 brand shown in the results box always carries the word TEST — Visa (TEST), Mastercard (TEST), Amex (TEST), Discover (TEST) — so the output is labelled at the point of use, not just in the article. If you see a card number without that label in your test data, do not trust it: either it is a real card, or it came from somewhere that does not label its test data. An credit card EMI calculator works out payments on a real card, a job where test numbers do not belong.

A worked example: five Visa test numbers

Press the button on this page with the defaults — 5 numbers, brand Visa — and you get five lines, each one a 16-digit test number starting with 4242. The count is 5, the length is 16, and the brand is Visa (TEST). Every press gives a different set, because the middle digits are random. None of them is a real card.

Each line passes the Luhn check. Take any line, 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 5, but the length is now 15, and every line starts with 378282. Switch to Mastercard and the length is back to 16, with every line starting with 555555. 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 real cards

A test card number and a real card number look the same: same length, same brand prefix, same Luhn check. The difference is not in the digits — it is in the world behind them. A real card was issued by a bank for a real account that holds real money. A test number was made by a random generator, and no account exists behind it.

That difference is everything. A payment charged to a real card takes real money from a real person. A payment attempted with a test number is declined in a live checkout, or triggers a fake approval in a gateway's test mode. Using a test number to try to pay for something real is not clever — it is a declined transaction at best, and fraud at worst. Never use these numbers outside testing.

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 four 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, and press Generate Test Cards. The numbers appear in the output box below, one per line, with the count, length, and brand shown in the results box above it. Remember: these are test data only, not real cards.

To make another set, press the button again — every press makes a fresh set. To copy the results, use the Copy button next to the output box. 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.

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 five 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.

Frequently Asked Questions

No. They are test data only — random numbers in well-known public test ranges, like Visa 4242, with a valid Luhn check digit, but no bank issued them and no account exists behind them. They must never be used for a real purchase. A real card comes only from your bank.

Because they are built correctly: the right brand prefix, the right length — 16 digits for Visa, Mastercard, and Discover, 15 for Amex — and a Luhn check digit worked out properly. Format validation checks the shape, not whether a card exists — that is exactly what makes them useful for testing and useless for real payments.

The Luhn algorithm is the check digit every card number carries. 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 number that fails Luhn is rejected by every payment form.

No. A test number is not a real card, so a live checkout will decline it, and trying to pay with numbers that are not yours is fraud. Use test numbers only in test mode, with a payment gateway's sandbox, and use your own real card for real purchases.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.