How to Generate Fake Credit Card Numbers for Testing
Choose a supported type, set a count when needed, and enable additional details for supporting fields. The tool returns fake card numbers for testing with a calculated check digit and optional expiration, security-code, and grouped-number data.
Using card-shaped data in a test
This tool creates fake credit card numbers for testing forms, checkout flows, validation messages, and other development checks. Choose a card type when a scenario depends on a particular number format, request several results for repeated input checks, or add supporting fields when the form expects more than a number. Treat every generated value as test data rather than as a payment credential, because the tool is intended to create fake numbers for testing.
Creating test card inputs
-
Choose a card type when the test depends on a particular format. The supported choices are
visa,mastercard,amex,discover, andvisa_electron. If you leave the type at its random setting, the tool selects one of those choices. An entry outside that set also causes a random choice, so use a listed value when the scenario requires a known type. -
Set the count when you need several results. Leaving the count empty produces one card. A supplied count is converted to an integer and constrained to a minimum of 1 and a maximum of 20. If the count cannot be converted through the supported conversion path, the tool uses one card; other conversion failures have no stated fallback.
-
Enable additional details when the receiving form needs supporting fields. Each result then includes an expiration month and year, a three-digit security code, and a grouped presentation of the number. Leave this option off when the test accepts only an ungrouped number.
-
Generate the results and inspect their shape. Visa, Mastercard, Discover, and Visa Electron numbers contain 16 digits, while Amex numbers contain 15. Each number includes a calculated check digit. The other non-prefix digits, expiration values, and security codes are generated with random choices, so separate generations can differ.
Reading the generated results
Start by checking the selected type and the resulting number length. An Amex result has 15 digits, whereas Visa, Mastercard, Discover, and Visa Electron results have 16 digits. If the type was left random, interpret the result according to the supported type that was selected rather than according to an assumed brand.
Next, compare the number of returned cards with the count after conversion and the 1-to-20 constraint have been applied. An empty count represents one generated card, while a handled conversion failure also produces one. When additional details are enabled, inspect the expiration month and year, security code, and grouped presentation as separate returned fields.
The calculated check digit describes how the number was formed, not whether it can authorize a transaction. Random number digits and optional values make the output useful for varying input checks, but they mean a generated result should not be treated as a stable production value.
Worked example
A developer is checking a checkout form that needs three Amex-shaped test records with supporting fields.
Select Amex, enter a count of 3, enable additional details, and generate the records.
The output contains three generated records. Each Amex number has 15 digits and a calculated check digit, and each record includes an expiration month and year, a three-digit security code, and a grouped number presentation.
Limitations
- These values are intended for testing; random content and a calculated check digit do not make them payment credentials, and an unsupported type may be replaced by a random supported type.
Common errors
- Entering a card type outside the supported choices can produce a randomly selected type; select
visa,mastercard,amex,discover, orvisa_electronwhen the test depends on a particular format.
FAQ
What happens if I do not enter a count?
An empty count produces one card. A supplied count is converted and constrained between 1 and 20, while a handled conversion failure uses one card.
How many digits does each card number have?
Amex numbers contain 15 digits. Visa, Mastercard, Discover, and Visa Electron numbers contain 16 digits.
What details can be included with a generated number?
Enabling additional details adds an expiration month and year, a three-digit security code, and a grouped presentation of the number to each result.