Test credit card numbers
Luhn-valid card numbers for checkout-form validation, fixtures and demos. They follow each network’s prefix and length rules but belong to no account.
Press generate to fill this table.
How the Luhn check works
Every card number ends in a check digit calculated with the Luhn algorithm (ISO/IEC 7812), invented by IBM’s Hans Peter Luhn in 1954. It catches any single mistyped digit and most swaps of neighbouring digits, so forms can reject typos before contacting the bank. Type a number and follow the steps.
- Starting from the right, double every second digit (highlighted).
- If doubling gives more than 9, subtract 9 (same as adding its two digits).
- Add everything up. The number is valid if the total ends in 0.
Sum = 80 → ends in 0: passes the Luhn check · Issuer by prefix: Visa
Passing Luhn only means the number is well-formed. Whether a real account exists, and whether it has funds, is up to the issuing bank.
Prefixes and lengths by network
| Network | Starts with | Length | Security code |
|---|---|---|---|
| Visa | 4 | 16 | 3 |
| Mastercard | 51–55, 2221–2720 | 16 | 3 |
| American Express | 34, 37 | 15 | 4 |
| Discover | 6011, 644–649, 65 | 16 | 3 |
| JCB | 3528–3589 | 16 | 3 |
| Diners Club | 36, 38, 300–305 | 14 | 3 |
Never store real card numbers in test databases. PCI DSS requires cardholder data to be protected wherever it’s kept, and synthetic numbers keep your test environments out of scope.
Questions people ask
Can these card numbers be used to buy things?
No. They pass the Luhn checksum so they get through form validation, but they aren’t linked to any account, have no funds and will be declined by any real payment processor. Using made-up card numbers to try to get goods or services is fraud.
Which numbers should I use with Stripe, PayPal or Adyen?
Payment gateways publish their own test cards that trigger specific sandbox results (success, decline, 3-D Secure). For example, Stripe’s 4242 4242 4242 4242 always succeeds in test mode. Use the gateway’s list for integration tests and these generated numbers for front-end validation and fixtures.
Why do different cards have different lengths?
Length and prefix (the IIN, first six to eight digits) are set per card network under ISO/IEC 7812. Visa and Mastercard use 16 digits, American Express 15 with a 4-digit security code, and Diners Club 14.