Skip to content

Test Credit Card Numbers: How the Luhn Check and Card Prefixes Work

Payment forms validate card numbers before a single request reaches your gateway. To test that validation you need numbers that look exactly right — correct prefix, correct length, valid checksum — but can never be charged. Here’s how they work.

Options

Tip: press Enter or Space to generate again.

Ready

Anatomy of a card number

  • IIN / BIN (first 6–8 digits): identifies the network and issuer — 4 for Visa, 51–55 and 2221–2720 for Mastercard, 34/37 for Amex.
  • Length: 16 digits for most networks, 15 for Amex, 14 for Diners Club.
  • Check digit: the final digit, calculated with the Luhn algorithm.

The Luhn algorithm, step by step

  1. Starting from the right, double every second digit.
  2. If doubling gives more than 9, subtract 9.
  3. Add all digits together.
  4. If the total is divisible by 10, the number is valid.

Luhn catches most single-digit typos and swapped neighbours — that’s why every checkout uses it.

Generated numbers vs gateway test cards

Generated numbers are perfect for front-end checks: card-type detection, formatting, Luhn validation and UI. For end-to-end tests against Stripe, Braintree, Adyen or PayPal sandboxes, use the official test cards those providers publish — they trigger specific approvals, declines and 3-D Secure flows.

Generated numbers are not linked to any account and will be declined by real processors. Using them to attempt purchases is fraud.

Pro tips

  • Test spaces and dashes in input — users type them.
  • Check that Amex shows a 4-digit CVV field.
  • Verify that the card logo switches as the user types the prefix.

Try a generator

Random Address Generator

Realistic street addresses with valid-format postal codes and phone numbers for 40 countries.

Fake Identity Generator

Complete fictional person profiles: name, birthday, address, phone, email, job and more.

Need random data? Get it now.

Pick any of 144 generators, hit Generate and copy or export the results as CSV, JSON or TXT. No account, no limits, nothing stored.

Start generating — free