FREE TOOL

Credit Card Generator: Luhn-Valid Test Card Numbers for Developers

A credit card generator for developers creates dummy card numbers that pass the Luhn checksum, so you can test checkout forms, validation rules and database fields without touching real financial data. These are synthetic numbers with no account behind them. The WritoryBuzz tool supports seven networks and exports your test data as CSV, JSON, SQL or Playwright code.

Generate test card numbers or keep reading to learn what the Luhn check really proves, which numbers payment gateways accept in test mode, and the mistakes that cause failed tests.

Use the tool
Quick start
1Choose a card network
2Set the number of cards
3Tick what you need
4Click Generate Cards

Generate Test Cards

Preview

VISA
4*** **** **** ****
JOHN DOEExpires 12/29
Generated: 0 Network: Visa Luhn valid: 100%
Quick answer:: What you get:
dummy card numbers that pass the Luhn check, with optional expiry date, CVV and cardholder name. Networks: Visa, Mastercard, American Express, Discover, JCB, Diners Club and UnionPay. Export: CSV, JSON, SQL and Playwright test format. For payment gateways: use that gateway's own documented test cards, not random numbers.

What Is a Credit Card Number Generator?

A credit card number generator builds a number with a valid structure: the right starting digits for a card network, the right length, and a final check digit that satisfies the Luhn formula. That is enough to pass the client-side validation most checkout forms run before a number is ever sent to a processor.

Passing the Luhn check says only that the digits are internally consistent. It does not mean a card exists, has funds or can be charged. A payment processor checks the number with the issuing bank, and a generated number fails that step every time.

Important

Do not use these numbers to try to pay for anything. Attempting to use fabricated card details on a real checkout is fraud or attempted fraud in India and most other countries, and gateways log every attempt.

What Is the Luhn Algorithm?

The Luhn algorithm, also called the modulus 10 check, is a simple checksum formula created by IBM scientist Hans Peter Luhn. He filed the patent in 1954 and it was granted in 1960. It is used for payment card numbers, IMEI numbers and several other identifiers, and it catches most single-digit typing errors and many swapped neighbours.

How the check works

  1. Starting from the right and excluding the check digit, double every second digit.
  2. If a doubled digit is greater than 9, subtract 9 from it.
  3. Add all the digits together, including the check digit.
  4. If the total is divisible by 10, the number passes.

A worked example

Take the number 4111 1111 1111 1111, a number widely used in documentation. Counting from the right, the 2nd, 4th and every other digit up to the 16th are doubled. The seven doubled 1s become 2s and add up to 14, and the leading 4 doubles to 8, so the doubled group totals 22. The eight digits left untouched are all 1s and add up to 8. The grand total is 30, which divides by 10, so the number passes.

Every number this tool generates is built so that the total reaches a multiple of 10. The Luhn check was designed for typo detection and not for security, so it offers no protection against anyone who deliberately builds a passing number.

How to Use the Credit Card Generator

  1. 1
    STEP 1 Choose a card network. Visa, Mastercard, American Express, Discover, JCB, Diners Club or UnionPay.
  2. 2
    STEP 2 Set the number of cards. Generate a single card or a batch for a test dataset.
  3. 3
    STEP 3 Tick what you need. Expiry date, CVV or CVC, and cardholder name are optional.
  4. 4
    STEP 4 Click Generate Cards. The preview card and a results list appear. The stats show the network and 100% Luhn valid.
  5. 5
    STEP 5 Export. Download as CSV, JSON, SQL or Playwright test code and paste it into your test suite.
Expert tip

Pick the network that matches the rule you are testing. A 15-digit American Express number should pass a form that expects 15 digits and a 4-digit CVV, and fail one that expects a Visa pattern.

Use the tool

Card Network Reference

NetworkStarting digits (BIN prefix)LengthCVV
Visa416 digits in this tool3 digits
Mastercard51 to 55, 2221 to 272016 digits3 digits
American Express34, 3715 digits4 digits
Discover6011, 6516 digits3 digits
JCB3528 to 358916 digits3 digits
Diners Club300 to 305, 36, 3814 digits3 digits
UnionPay6216 to 19 digits3 digits

The first six to eight digits are the Bank Identification Number (BIN), also called the Issuer Identification Number, which tells software which network and issuer a card belongs to. Visa also issues 13 and 19 digit numbers, and Discover uses additional ranges, so real world validators cover more cases than this table.

Using Test Cards With Payment Gateways

Do not feed random Luhn-valid numbers to a payment gateway and expect them to work. Gateways publish their own test card numbers, and those are the only ones accepted in sandbox mode.

GatewayWhat to useNotes
StripeTest mode with sk_test_ keys and the documented test cards, such as 4242 4242 4242 4242 with any future expiry and any CVCStripe lists other numbers that trigger declines, 3D Secure and specific error codes. Random numbers are declined in test mode.
PayPalSandbox accounts created in the PayPal Developer DashboardUse sandbox buyer accounts and the card details PayPal's sandbox provides.
BraintreeSandbox with Braintree's documented test card numbersEach number triggers a defined outcome, so use the list in Braintree's docs.
Razorpay and other Indian gatewaysTest mode keys and the test cards in the provider's own docsEach provider publishes its own list. Check the current documentation before you test.

What this generator is for: front-end validation, form masks, database column sizes, parsing and formatting code, and mock data for demos. What it is not for: end-to-end tests that go through a payment gateway. For those, use the gateway's documented test numbers.

Developer and QA Use Cases

Form validation

Confirm that a checkout form rejects a number that fails the Luhn check and accepts one that passes.

Card brand detection

Test that your UI shows the right network icon for each BIN range.

Input masks and formatting

Check spacing for 15, 16 and 19 digit numbers.

Database and API testing

Fill test tables and fixtures with realistic, harmless data. Pretty-print the output with the JSON formatter.

Demos and training

Show a payment page in a tutorial without exposing real card details.

Automated tests

Export Playwright code and run it against a staging build.

Need dummy text for the same demo? Use the lorem ipsum generator. If your test accounts need login credentials, create them with the password generator.

Common Mistakes

  • Expecting the number to work on a live site. It cannot. There is no account behind it.
  • Using generated numbers on a production endpoint. It will be declined and logged, and repeated attempts can flag your merchant account for review.
  • Assuming Luhn-valid means a real card. It means the digits are consistent, nothing more.
  • Testing the gateway with random numbers. Use the gateway's own test card list.
  • Forgetting the CVV length. American Express uses 4 digits and most others use 3.
  • Putting real card data into a test database. Real numbers bring PCI DSS obligations. Dummy numbers avoid that.

Limits of This Tool

  • The numbers are synthetic and cannot be authorised by any bank.
  • Passing Luhn does not exercise bank checks, fraud rules, 3D Secure, AVS or the gateway's own validation.
  • Network rules change. Always check your gateway's documentation for the current BIN ranges it recognises.
  • The tool does not integrate with any gateway and cannot simulate declines or 3D Secure.

Is It Legal to Use a Credit Card Generator?

Generating dummy numbers for software testing is a normal developer practice. Using generated numbers to attempt a purchase, to get past a free trial that asks for a card or to deceive any business is illegal. If you are testing a payment flow, do it in a sandbox you control.

Privacy

The live page does not ask for a real card number, and you should never type one into any generator or test tool. If you want to state that generation runs in your browser, confirm that with the developer first, since the captured live page text does not say so.

Open the tool

Frequently Asked Questions

Are the numbers from this credit card generator real?

No. They are synthetic numbers that pass the Luhn check but are not linked to any bank or account. They cannot be charged or used to buy anything.

Is it legal to use a credit card generator?

It is legal to generate dummy numbers for software testing. It is illegal to use them to attempt a real payment or to deceive a business, and gateways log every attempt.

What is the Luhn algorithm?

It is a checksum formula, also called modulus 10, created by IBM's Hans Peter Luhn. You double every second digit from the right, subtract 9 from results above 9, add everything and check that the total divides by 10.

Will these numbers work in Stripe test mode?

Not reliably. Stripe test mode accepts its own documented test cards, such as 4242 4242 4242 4242 with a future expiry and any CVC. Random Luhn-valid numbers are declined, so use Stripe's list for gateway tests.

What are these numbers good for, then?

Testing form validation, card brand detection, input masks, database fields and demo screens. They check that your own code handles a plausible number correctly.

Which card networks does the tool support?

Visa, Mastercard, American Express, Discover, JCB, Diners Club and UnionPay. Each uses the right starting digits and length for that network.

Why does American Express have a 4-digit CVV?

American Express uses a 4-digit security code on the front of the card, and a 15-digit number. Visa, Mastercard and most others use a 3-digit code on the back.

Can I export the generated cards?

Yes. The tool exports to CSV, JSON, SQL and Playwright test format, so you can load them into fixtures or automated tests.

What does BIN mean?

BIN stands for Bank Identification Number. It is the first six to eight digits of a card number and tells software the network and issuer. Generate test card numbers Remember: dummy numbers are for your own sandbox and test suites only.

Ready to try the Credit Card Generator?

Free to use. Open the tool and get your result in seconds.

Use the tool
For contributors
Got something worth sharing? Write for us.

Original, well researched guides are always welcome here.

  1. 1Read the guidelines
  2. 2Send us your pitch
  3. 3Our editors review it