Credit Cards

Sandbox Card Numbers Explained: What They Are and How to Use Them Safely

PAYATE Team· · 3 min read
SPAYATE

If you have ever built a checkout form, you have needed a card number to type into it — without using your own real card over and over. That is exactly what a sandbox card number is for. This guide explains what they are, why a made-up number can still "look valid", and how to use them without getting into trouble.

What is a sandbox card number?

A sandbox card number is a randomly generated, fake card number that is built to satisfy two things: the Luhn checksum and a real card-scheme prefix (so it starts like a Visa, Mastercard, Amex and so on). That is all. It is not connected to any bank account, it holds no money, and no one can buy anything with it.

You can create a batch of them instantly with the Card Toolkit — pick a scheme, choose how many, and it generates dummy numbers (with optional expiry and CVV) you can paste straight into a form.

Why a fake number still "passes"

Almost every card number ends in a check digit calculated with the Luhn algorithm. The formula doubles every second digit from the right, adds everything up, and a valid number makes that total a multiple of 10. It is a simple typo-catcher used by nearly every payment form.

Crucially, Luhn says nothing about whether an account exists — it is pure arithmetic on the digits. So any number constructed to satisfy the formula will "pass" a Luhn check. That is a feature, not a bug: it lets you check that your form accepts well-formed input and rejects typos, without touching a real card.

Prefixes identify the brand

The first digits — the IIN/BIN — tell you the scheme. Numbers starting with 4 are Visa; 51–55 and 2221–2720 are Mastercard; 34 and 37 are American Express; and so on. A good sample number uses a real prefix so your brand-detection logic lights up correctly. To inspect the bank and country behind a real card's BIN, use the BIN Lookup.

How developers actually use them

  • Front-end validation: check that your input mask groups digits (4-4-4-4, Amex 4-6-5), detects the brand, and flags a bad checksum before submitting.
  • UI states: fill a realistic-looking checkout for screenshots, samples and QA without exposing a real card.
  • Edge cases: check unusual lengths, Amex 15-digit numbers, and what happens when the Luhn check fails.

To verify a number you already have — real or generated — the Card Validator runs the Luhn check and identifies the scheme, while the Format tab of the Card Toolkit cleans and masks it.

Where sample numbers stop — use the sandbox instead

Generated numbers only exercise your own code. The moment the card data leaves your form for a real payment gateway, a random Luhn-valid number will be declined — it is not a real card. For a true end-to-end check (authorization, 3-D Secure, refunds, webhooks), you must use the official sample numbers your gateway publishes, in its sandbox/check mode:

  • Stripe: 4242 4242 4242 4242 (and a long list for specific scenarios)
  • PayPal, Adyen, Braintree, Square: each has its own sandbox card set in its docs

Those numbers are wired into the gateway's sample environment so they return predictable results — approved, declined, insufficient funds, and so on.

Staying on the right side of the line

Generating dummy numbers for QA is normal and legitimate — but the intent matters. Using any card number, real or generated, to attempt fraud or to probe live systems is illegal. Keep generated numbers to your own development and QA, and never enter a stranger's real card details anywhere.

Quick summary

  • A sandbox card number is fake but Luhn-valid with a real scheme prefix.
  • It passes a checksum because Luhn is just arithmetic — it proves nothing about a real account.
  • Use the Card Toolkit to generate and format them for front-end QA.
  • Use your gateway's official sandbox numbers for real end-to-end payment checks.

Frequently asked questions

Are sandbox card numbers real credit cards?
No. They are random numbers that only satisfy the Luhn checksum and a card-scheme prefix. They are not linked to any bank account, hold no money, and cannot buy anything.
Why does a fake number pass the Luhn check?
Luhn is only a formula over the digits — it has nothing to do with whether an account exists. Any number built to satisfy that formula will "pass", which is exactly why it is useful for QA form validation.
Can I use generated numbers to make a real check payment?
No. For an end-to-end payment check you must use your gateway's official sample numbers in its sandbox (for example Stripe's 4242 4242 4242 4242 in check mode). Generated numbers only exercise your own front-end validation.
Is it legal to generate sandbox card numbers?
Generating Luhn-valid numbers for software QA is common and legitimate. Using any card number, real or generated, to attempt fraud is illegal. These tools are for development and QA only.

Try the tools

P
Written by PAYATE Team

The PAYATE team builds free tools for merchants and developers.

More PAYATE tools