Xerobit

Credit Card Generator for Test Data

This credit card generator creates Luhn-valid test numbers for Visa, Mastercard, Amex, Discover, Diners Club and JCB, number and brand only (sandboxes accept any future expiry and security code). For testing form validation and software only: using card numbers to obtain goods or services is fraud.

Result

  1. 4496831731599834
  2. 4610784467132224
  3. 4705392991435208
  4. 4343270124427201
  5. 4455304184277869
NumberBrand
4496831731599834Visa
4610784467132224Visa
4705392991435208Visa
4343270124427201Visa
4455304184277869Visa

For testing form validation and software only. Random numbers are not guaranteed to be unassigned, and using card numbers to obtain goods or services is fraud. Sandbox cards accept any future expiry and any security code. Published sandbox number for Visa: 4242 4242 4242 4242.

How to use the credit card generator

  1. Select the card brand you need test data for from the dropdown menu.
  2. Enter how many test credit card numbers to generate (a whole number from 1 to 20).
  3. Click Generate to produce the results.
  4. Copy the numbers into your test environment. Use any future expiry date and any security code with a payment sandbox.

How the Luhn algorithm works

Every valid payment card number passes the Luhn checksum, also known as the mod 10 algorithm. This credit card generator builds numbers that satisfy this check so they are accepted by form validation logic during development.

The process works right to left. Starting from the second-to-last digit, double every other digit. If doubling produces a number greater than 9, subtract 9. Sum all the digits together. The check digit is the amount needed to bring that sum to the next multiple of 10.

For example, take the partial Visa prefix 411111111111111. Doubling every second digit from the right and summing gives 29. The check digit is (10 - (29 % 10)) % 10 = 1, producing the well-known test number 4111111111111111.

Brand prefixes and lengths

Each card network reserves specific starting digits (the Issuer Identification Number) and total lengths. A luhn credit card generator must respect these rules to produce output that looks structurally correct to validation libraries.

BrandPrefixTotal LengthSecurity Code Length
Visa4163
Mastercard51 through 55163
American Express34 or 37154
Discover6011163
Diners Club36143
JCB3528 through 3589163

Published test numbers

Payment processors publish specific test card numbers for integration testing. Sandbox and test modes such as Stripe, Braintree and PayPal recognize them, and they accept any future expiry date and any 3 digit security code (4 digits for American Express). Prefer these over random numbers whenever a gateway is involved.

BrandTest Number
Visa4242 4242 4242 4242
Mastercard5555 5555 5555 4444
American Express3782 822463 10005
Discover6011 1111 1111 1117

All of these pass the Luhn check. Use this credit card number generator when you need many distinct values for form validation tests, database seeding or load testing without a gateway. This tool does not generate expiry dates or security codes, because sandboxes accept any valid-looking ones.

When to use generated test data

Developers need fake credit card numbers whenever a checkout flow, subscription system or payment form requires input that passes client-side validation without contacting a live processor. Common scenarios include:

  • End-to-end UI tests that fill out a checkout form automatically.
  • Seeding a staging database with realistic-looking customer records.
  • Verifying that your backend correctly identifies card brands from the BIN range.
  • Testing error handling by submitting numbers that fail the Luhn check intentionally.

This tool pairs well with other test-data utilities. Use the fake name generator for cardholder names, the UUID generator for transaction IDs, or the token generator for API keys in your test harness.

Security and limitations

These numbers are for testing form validation and software only. They are generated to pass format checks and are not issued to you, but a random Luhn-valid number on a real issuer range may coincide with a real account, so they are not guaranteed to be unassigned. Using card numbers to obtain goods or services is fraud, whatever the source of the number.

Because everything is computed locally using crypto.getRandomValues, no data leaves your machine. If you need to verify whether an existing number is structurally valid rather than generating new ones, use the credit card validator instead.

Why a valid card number will not work for purchases

People searching for a valid credit card number often expect one that will pay for something. A generated number cannot do that. The Luhn check only catches typing mistakes. It does not mean an account exists. A real payment also needs a number issued to a cardholder, a matching expiry date and security code, and approval from the issuing bank. A random Luhn-valid number fails at that last step.

These numbers are test data for software. Card networks and payment providers publish their own test cards for this purpose, and payment systems run in test mode accept them without moving money. Stripe lists its test cards at docs.stripe.com/testing, including 4242 4242 4242 4242 for Visa and 5555 5555 5555 4444 for Mastercard, with any future expiry date and any 3 digit security code (4 digits for American Express). If you need a temporary number for your own online spending, ask your card issuer about virtual cards. Do not use generated numbers for that.

Worked examples

ExampleInputResult
Five Visa numbersCard brand: visa; Number of cards: 54033916543086375, 4463267457769898, 4278542237445554, 4035906987203725, 4499694366456812
Three Amex numbersCard brand: amex; Number of cards: 3375965107658909, 370715261976208, 375678424113629
One MastercardCard brand: mastercard; Number of cards: 15594742970197461
Ten Discover numbersCard brand: discover; Number of cards: 106011793289376026, 6011261992837536, 6011856118048262, 6011371990485442, 6011759428283761, 6011991298089818, 6011911891356984, 6011105900401234, 6011028608632704, 6011286887514338

FAQ

Are these real credit card numbers?

They are random numbers made to pass the Luhn check and match brand prefixes, not cards issued to anyone. They are not guaranteed to be unassigned, because a random number on a real issuer range can coincide with a real account. Use them only for testing form validation and software.

Can I use these numbers to buy anything or sign up for a free trial?

No. Using card numbers to obtain goods or services is fraud. This tool exists for developers who need valid-looking numbers to test forms and software.

Why do the numbers need to pass the Luhn check?

Most payment forms validate the Luhn checksum before sending data to a server. Luhn-valid numbers let your test suite pass client-side validation without errors.

Why are there no expiry dates or CVV codes?

Payment provider sandboxes accept any future expiry date and any 3 digit security code (4 digits for American Express), so generated ones add nothing for developers. Use the published sandbox cards such as 4242 4242 4242 4242 for gateway testing.

What is the difference between this tool and published test numbers?

Published sandbox numbers like 4242 4242 4242 4242 are static values recognized by payment test modes. This tool generates different random numbers each time, which is useful for validation tests, database seeding or load testing.

Is my data sent to a server?

No. The generation happens entirely in your browser using JavaScript. Nothing is transmitted over the network.

Does a valid credit card number mean the card works?

No. A number that passes the Luhn check is only correctly formed. It has to be issued to a cardholder and approved by the issuing bank to pay for anything, and a generated number is not.

Can I get a free working credit card number from this generator?

No. This tool makes test numbers for checking forms and software, and they cannot be used to pay. For development, use the test cards your payment provider publishes, such as those at docs.stripe.com/testing.

Where can I find official test card numbers?

Payment providers publish them in their documentation. Stripe lists Visa, Mastercard, American Express and Discover test cards at docs.stripe.com/testing. Use any future expiry date and any 3 digit security code (4 digits for American Express) in test mode.