What is a test credit card number?
A test credit card number is a number that looks and behaves like a real card number in every check a website can run on its own — the right brand prefix, the right length and a correct check digit — but that no bank has ever issued. It is not linked to an account, a person or any money. Developers and testers use these numbers to check checkout forms, payment flows and databases without exposing real customer data.
The generator above builds each number the same way card networks do: it starts with a genuine issuer prefix (the IIN or BIN), fills the account digits at random with your browser's cryptographic random generator, and calculates the final digit with the Luhn algorithm. It then adds a random future expiry date and a security code of the right length for the brand. Everything happens on your device; nothing is sent to our server.
Card number format by brand
The first digits of a card number identify the network and issuing bank. This table lists the ranges the generator uses, so you can see what your validation code needs to accept.
| Brand | Starts with (IIN) | Length | Security code |
|---|---|---|---|
| Visa | 4 | 16 (also 13 and 19) | 3-digit CVV2 on the back |
| Mastercard | 51–55 and 2221–2720 | 16 | 3-digit CVC2 on the back |
| American Express | 34 and 37 | 15 | 4-digit CID printed on the front |
| Discover | 6011, 644–649, 65 (and 622126–622925) | 16 (up to 19) | 3-digit CID on the back |
| JCB | 3528–3589 | 16 (up to 19) | 3-digit CAV2 on the back |
| Diners Club | 300–305, 36, 38–39 | 14 (up to 19) | 3-digit code on the back |
| UnionPay | 62 | 16–19 | 3-digit CVN2 on the back |
| Maestro | 5018, 5020, 5038, 5893, 6304, 6759, 6761–6763 | 12–19 | 3-digit code (optional on some cards) |
How the Luhn check digit works
The Luhn algorithm (also called mod 10) was published by IBM engineer Hans Peter Luhn in the 1950s and is used by every major card brand to catch typing mistakes. Take the well-known test number 4111 1111 1111 1111:
- Starting from the rightmost digit, double every second digit (the highlighted ones in the table).
- If doubling gives a number above 9, subtract 9 (so 8 stays 8, but 7×2 = 14 becomes 5).
- Add up all the values. Here the total is 30.
- If the total ends in 0, the number is valid. 30 is a multiple of 10, so this number passes.
| Digit | 4 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Doubled? | 8 | – | 2 | – | 2 | – | 2 | – | 2 | – | 2 | – | 2 | – | 2 | – |
| Value added | 8 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 |
To generate a number, we do the same thing in reverse: fill every digit except the last, compute the sum, and choose the final digit that brings the total to the next multiple of 10. You can check any number step by step with our credit card validator.
How to use the generator
- Pick a brand — Visa, Mastercard, American Express, Discover, JCB, Diners Club, UnionPay or Maestro.
- Optionally enter a BIN or pattern. A 6–8 digit BIN creates numbers for a specific issuer range. Use
xas a wildcard (for example5425xxxxxxxx1234) to fix some digits; the generator keeps every digit you type and solves one wildcard so the number still passes Luhn. - Choose quantity and details — up to 1,000 cards, a random or fixed expiry month and year, and a random or fixed CVV.
- Export — copy the list or download it as CSV, JSON, XML or pipe-separated text (
number|mm|yyyy|cvv).
What developers use test card numbers for
- Form validation: make sure your checkout accepts every brand and length (15-digit Amex, 2-series Mastercard, 19-digit cards) and rejects numbers with a wrong check digit.
- Brand detection and input masks: confirm the right logo appears and numbers are grouped correctly (4-4-4-4 or 4-6-5 for Amex).
- Test data and fixtures: seed staging databases, demos and screenshots with realistic numbers instead of real customer cards, which keeps you out of PCI DSS scope.
- Load and UI testing: generate hundreds of distinct records for performance tests, pagination and search.
- Teaching: show how IINs, check digits and the Luhn formula work.
Testing with a payment gateway
When you test a real payment integration in sandbox mode, use the gateway's own documented test cards. They are wired to return specific results such as approvals, declines or 3-D Secure challenges, which random numbers cannot do. Generated numbers are ideal for everything that happens before the request reaches the gateway. Official test card lists:
Frequently asked questions
Are these real credit card numbers?
No. The numbers follow the public format rules of each card network (prefix, length and Luhn check digit), but they are not linked to any bank account, cardholder or credit line. They exist only to test software.
Can I buy something or start a free trial with a generated card?
No. A real payment needs an authorization from the issuing bank, and no bank has issued these numbers, so every charge is declined. Trying to pay with a number you do not own is fraud. Use them only in sandboxes, forms and test data.
Why do the numbers pass card validation?
Most checkout forms only check the format: the brand prefix, the length and the Luhn checksum. Our numbers are built to satisfy those three rules, which is exactly what you need to test validation code. A payment gateway in live mode will still reject them.
Are the expiry date and CVV real?
They are random values in a realistic format: a future month/year and a 3-digit code (4 digits for American Express). You can also fix the month, year or CVV if your test case needs a specific value.
Can I generate cards from a specific BIN?
Yes. Type a BIN (the first 6–8 digits) in the BIN / pattern field. You can also use x as a wildcard, for example 453201xxxxxxxxxx. Every x is filled at random and the check digit is calculated so the result passes Luhn.
Which format should I export?
Use the pipe format (number|mm|yyyy|cvv) for quick copy-paste, CSV for spreadsheets and test fixtures, JSON for API mocks and unit tests, and XML for older integrations. You can generate up to 1,000 cards at once.
Is it legal to generate test card numbers?
Generating numbers that follow a published format is legal and is how payment software is tested every day. What is illegal is using any card number you are not authorized to use. This site does not store, sell or process real card data.