CalculatorsConvertersDeveloperTextAll toolsDirectory
Submit your tool Sign in
Theme
Home/Answers/Developer
How-to

Where do I get test credit card numbers for testing a checkout form?

Short answer

Use numbers that pass the Luhn checksum but are not real cards. Card forms validate the number format with the Luhn algorithm, a checksum over the digits, so a Luhn-valid fake number exercises your validation exactly like a real one. A browser-based test number generator creates such numbers locally, for testing only; for end-to-end payment tests, use the sandbox numbers your payment provider documents.

How card number validation works

Almost every checkout form runs the Luhn check before anything is sent to a payment processor: double every second digit from the right, sum the digits, and the total must end in zero. A generator that produces Luhn-valid numbers lets you test that your form accepts well-formed numbers and rejects typos, without ever typing a real card into a test environment.

What these numbers are and are not

Generated numbers pass the format check only. They are not connected to real accounts and will not authorize a charge. That is the point: they are safe to paste into forms, commit into test fixtures and share in bug reports. For full end-to-end tests against a payment gateway, use the dedicated sandbox test numbers your provider publishes in its documentation, since gateways recognize those specifically.

Keep real cards out of test flows

Typing a real card number into a staging environment risks it landing in logs, screenshots or analytics. Generating fake numbers in your browser keeps the whole test loop on your device: nothing is uploaded, and no real payment data exists anywhere in your test suite.

Step by step

  1. Generate a number. Open the test number generator and create a Luhn-valid card number in your browser.
  2. Test your validation. Paste it into your checkout form and confirm the format validation accepts it.
  3. Test the failure path. Change one digit to make the checksum fail and confirm your form rejects it.
  4. Use sandbox numbers for gateway tests. For tests that reach your payment provider, switch to the sandbox numbers from its documentation.

Frequently asked questions

Can these numbers be charged?

No. They only pass the Luhn format check and are not linked to any real account, so they cannot authorize a payment.

Why do I need Luhn-valid numbers at all?

Because checkout forms reject numbers that fail the checksum, a random string of digits usually will not get past the first validation step.

Is anything sent to a server when I generate one?

No. The numbers are generated entirely in your browser.

Related answers