Test card number generator

Generate Luhn-valid test card numbers for QA and development, or check a number and detect its brand. These are test numbers only, never real accounts.

These are test numbers for QA and development. They pass the Luhn check and match a real card format, but they are not real accounts, are linked to nobody, and cannot be charged.

How do I generate a test card number?

Pick a brand (Visa, Mastercard, American Express or Discover) and a quantity, then press Generate. The tool builds numbers with the correct starting digits and length for that brand, fills the middle with random digits, and works out the final check digit so each number passes the Luhn algorithm. These are test numbers for development only. They pass the format checks but are not real accounts, are linked to nobody, and cannot be charged.

Test numbers, not real cards

This tool makes card numbers that are the right shape for testing software: they start with the correct digits for the brand, have the right length, and pass the built-in checksum that every payment form runs. What they are not is real. No bank has issued them, they are tied to no account, and they cannot be charged a penny. They exist so you can check that a checkout, a booking form or a validation script handles a card-shaped number properly, before you go anywhere near real money.

Pick a brand and a quantity, press Generate, and you get a list you can paste straight into your own test suite. Switch to the Check tab to run any number through the same checksum and see which brand it looks like. Everything happens in your browser, so nothing you type is uploaded and no bank is ever contacted.

How the Luhn check works

Almost every card number carries a self-check built into its last digit, using the Luhn algorithm (also called mod 10). It is a quick way to catch a mistyped digit before a payment is even attempted. Working from the right, you double every second digit. If doubling gives a number above 9, you subtract 9. Then you add every digit together. A valid number is one whose total divides exactly by 10.

Double every 2nd digit from the right (subtract 9 if over 9), sum all digits, and a valid number has (sum mod 10) = 0.

The generator uses this in reverse: it lays down the brand prefix, fills the middle with random digits, then works out the one final digit that makes the whole sum land on a multiple of 10. The checker just runs the sum and tells you whether it passes.

Visa test number 4242 4242 4242 4242
Luhn digits sum to 80, and 80 divides by 10, so it is valid
Amex test number 3782 822463 10005
Digits sum to 60, which divides by 10, so it is valid
Change the last digit to 4242 4242 4242 4241
The sum becomes 79, which does not divide by 10, so it fails

Why test card numbers exist

When you build anything that takes payment, you need to try it long before real cards are involved. Payment providers such as Stripe, PayPal and Adyen give you a sandbox for exactly this: a copy of their system that behaves like the real thing but moves no money. They publish their own specific test numbers that trigger set results, such as a clean approval, a declined card or a number that asks for extra authentication.

Before your code ever reaches the provider, though, your own form has work to do: rejecting obviously wrong input, spacing the digits as the user types, spotting the brand from the opening digits, and flagging a failed checksum. Generic Luhn-valid numbers like the ones here are ideal for that first layer. They let you seed a database of test orders, fill in demo screenshots, or check that your validation lights up green and red in the right places.

Use them for testing only

It is worth being blunt about the line here. These numbers are safe because they are fake, and they are only useful because they are fake. They will be declined by any genuine payment system, because the account behind them simply does not exist. Using a generated number to attempt a real purchase, claim a free trial or get around a paywall is card fraud, and it does not work anyway.

So treat this as a developer and QA tool. Generate a batch, wire them into your tests, and check your form does the right thing. When you need to test an actual transaction path, use the dedicated test numbers your payment provider gives you, because those are the ones tied to their sandbox outcomes. This is a testing aid, not payment or financial advice.

How we work it out

Each number starts with a brand-specific prefix (Visa 4; Mastercard 51 to 55 or 2221 to 2720; American Express 34 or 37; Discover 6011 or 65) and has the right length (15 digits for Amex, 16 otherwise). The middle digits are drawn from crypto.getRandomValues, then the final digit is set to the Luhn check digit so the whole number validates. The checker runs the same Luhn test and matches the prefix to detect the brand.

Frequently asked questions

Are these real card numbers?

No. They are test numbers that pass the Luhn check and look like the right brand, but they are not issued to anyone and are not linked to any bank account. They cannot be used to pay for anything and cannot be charged. They exist only to test that software handles a card-shaped number correctly.

What is the Luhn check?

The Luhn algorithm is a simple checksum used on card numbers to catch typos. Working from the right, every second digit is doubled (subtracting 9 if the result is over 9), all the digits are added up, and a valid number has a total that divides exactly by 10. It catches most single-digit mistakes and many swapped-digit errors.

Why do payment sandboxes need test numbers?

Payment providers like Stripe, PayPal and Adyen give you a sandbox so you can build and test a checkout without moving real money. They publish specific test numbers that trigger set outcomes, such as a successful payment or a declined card. Generic Luhn-valid numbers are useful for testing your own form validation before you reach the provider.

Can I use these to make a purchase or get a free trial?

No, and trying would be fraud. These numbers are not tied to any real account and will be declined by any genuine payment system, because the card does not exist. They are only for testing your own software against a correctly formatted number.

How does the brand checker work?

Paste a number into the Check tab and it strips spaces and dashes, runs the Luhn test, and matches the opening digits against the standard brand ranges to name Visa, Mastercard, American Express or Discover. It never contacts a bank or a server, so it only tells you whether the number is well formed, not whether an account exists.

Related tools