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.

Card numbers

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.

  1. Starting from the right, double every second digit (highlighted).
  2. If doubling gives more than 9, subtract 9 (same as adding its two digits).
  3. Add everything up. The number is valid if the total ends in 0.
Digit4539148803436467
Value8569247803833437

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

NetworkStarts withLengthSecurity code
Visa4163
Mastercard51–55, 2221–2720163
American Express34, 37154
Discover6011, 644–649, 65163
JCB3528–3589163
Diners Club36, 38, 300–305143

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.

Related generators