How to use the test card number generator
- 1Choose a Card network (prefix) and the Quantity.
- 2Press Generate numbers. Untick Group digits with spaces to get plain digits.
- 3Press Copy all, CSV or JSON to use them in your tests.
- 4Paste any number into the Luhn validator to check its checksum and prefix.
Three Visa-prefix test numbers (one run) and a validator check
Visa · Quantity 3 Validator: 4242 4242 4242 4242 and 4242 4242 4242 4243
4387 7257 9634 3223 4233 7923 1759 8624 4004 5766 3281 2803 4242 4242 4242 4242 passes (Visa prefix, 16 digits) 4242 4242 4242 4243 fails: the last digit would need to be 2
What these numbers are and aren't
These are test numbers: a network prefix followed by random digits and a check digit, so they pass the same Luhn check that payment forms run before submitting. They're useful for testing input masks, card-type detection, validation messages and database fields.
They aren't issued by any bank, have no expiry date or security code, and aren't linked to an account. A payment gateway will decline them at authorization. Using made-up numbers to obtain goods, services or free trials is fraud in most countries; this page is for software testing only.
How the Luhn check works
The Luhn algorithm (ISO/IEC 7812-1) catches single-digit typos and most swapped neighbors:
- Starting from the right, double every second digit (the check digit itself is not doubled).
- If doubling gives more than 9, subtract 9.
- Add all the digits. The number is valid when the total is a multiple of 10.
For 4242 4242 4242 4242 the total is 80, so it passes; change the last digit to 3 and the total is 81, so it fails. The generator works backwards: it picks every digit except the last, then chooses the last digit that makes the total a multiple of 10.
Card prefixes by network
The first digits (the IIN or BIN) identify the network and card length:
| Network | Prefix | Length |
|---|---|---|
| Visa | 4 | 16 |
| Mastercard | 51–55, 2221–2720 | 16 |
| American Express | 34, 37 | 15 |
| Discover | 6011, 644–649, 65 | 16 |
| JCB | 3528–3589 | 16 |
| Diners Club International | 36 | 14 |
| UnionPay | 62 | 16 |
Some networks also issue other lengths (Visa 13 or 19 digits, for example). Make your form accept 12 to 19 digits and rely on the gateway for the final check.
Use your gateway's official test cards
To test payments end to end (authorization, 3-D Secure, declines, refunds), use the sandbox and published test cards from your provider. Stripe documents numbers such as 4242 4242 4242 4242 with outcomes for each, and PayPal's sandbox has its own card generator. Those numbers trigger predictable responses in test mode and are rejected in live mode.
Never use real customer card numbers in test environments; PCI DSS requires that live card data stays out of development and testing.
Is anything I enter stored?
This tool runs entirely in your browser. Your text is not uploaded to our servers.
