About the Test Credit Card Number Generator
Testing a payment form needs numbers that pass client-side validation without being real cards. This generator produces numbers with the correct brand prefix and a valid Luhn check digit, along with a plausible expiry and CVV, for Visa, Mastercard, American Express, Discover, JCB and Diners Club. They will pass format validation and be rejected by any real processor, which is exactly what test data should do.
Each brand owns a prefix and a length, and both have to be right or a form rejects the number before it ever looks at a check digit. Visa begins with 4 and runs to 16 digits, Mastercard uses 51 to 55 or the newer 2221 to 2720 range at 16, American Express uses 34 or 37 at 15 digits, Discover 6011 or 65 at 16, JCB 3528 to 3589 at 16, and Diners Club 36 or 38 at 14. The digits in between are random, and the final one is chosen so the Luhn total lands on a multiple of ten.
The detail that breaks test scripts is the security code. American Express prints a four-digit code on the front of the card while every other brand uses three on the back, so a fixture that hard-codes three digits fails as soon as it meets an Amex number.
These numbers are random and not linked to any account, so they cannot be charged. Filling a staging checkout to see how the form behaves is what they are for. For actual payment integration tests, use the official test numbers your processor publishes, since those trigger specific responses such as a decline or a 3-D Secure challenge. To check a number, use the Credit Card Validator.
How to use
- Choose the brand and how many.
- Copy the numbers into your test form.
- Use your processor's official test cards for integration tests.
Common questions
- Can these numbers be charged?
- No. They are random, not linked to any account, and any processor will decline them.
- Why do they pass validation?
- They have the right prefix and a correct Luhn check digit, which is all client-side validation checks.
- Should I use these with Stripe or PayPal test mode?
- Use the official test numbers those services publish; they trigger defined responses. These are for format testing.