Test data only. Local fixtures do not issue cards, verify accounts or provide payment authorization. Use them only in authorized tests. Why?
5 test cards
- Generated fields are not uploaded
- Randomly generated in your browser
- Every number passes the Luhn check
Choose a fixture for the question you are testing
This tool creates synthetic numbers, expiry fields, security codes and placeholder names for local form tests. The practical choice is which input will expose your defect: a brand transition, a length boundary, a malformed value, an export conversion or a gateway response. Those jobs need different fixtures.
| What you need to test | Use | Expected evidence |
|---|---|---|
| A form populated with one or several brands | The generator above | Labels, grouping and synthetic fields render correctly |
| Malformed input, prefix ambiguity or length boundaries | The shared validation bundle below | Separate expected results for characters, prefix, length and checksum |
| A specific prefix and total digit count | Prefix generator | The generated number retains the requested shape |
| A larger seeded dataset | Bulk generator | The export matches that tool’s separate schema and recorded settings |
| Gateway approval, decline or authentication | Homepage scenario selector | Required inputs and documented expectations for selected Stripe and PayPal tests |
Use the generator controls
- Choose a network tile, or use the Card type menu on mobile. The page starts with a generated Visa example. Mixed selects from Visa, Mastercard, Amex and Troy.
- Choose 1–25 records with the quantity controls. Changing the network or quantity generates a fresh set; it does not preserve the previous one.
- Use Generate new card or Generate N cards for another random batch. Repeated values are possible, and a mixed batch does not guarantee coverage of every brand.
- For a single result, copy individual fields or all details. For multiple results, choose List, JSON or CSV before copying the batch. JSON and CSV download buttons save files; changing the preview format does not regenerate the values.
What this tool actually emits
| Network | Configured prefixes | Lengths |
|---|---|---|
| American Express | 34, 37 | 15 |
| Diners Club | 300–305, 36, 38, 39 | 14 |
| Discover | 6011, 65, 644–649 | 16 |
| JCB | 3528–3589 | 16 |
| Maestro | 50, 56–58, 6304, 6759, 6761–6763 | 16, 19 |
| Mastercard | 51–55, 2221–2720 | 16 |
| Troy | 9792 | 16 |
| UnionPay | 62, 81 | 16, 19 |
| Visa | 4 | 16 |
Every generated number has a calculated Luhn check digit. The security code is a random string of the configured length, not a code derived from the number. Expiry years are chosen one to five calendar years ahead of generation, so save an export when exact fixture values matter.
There is no per-prefix or per-length selector here. The length comparison shows the generator’s subset next to the wider local validation profile. Neither table promises what a merchant accepts.
Preserve the export contract
JSON contains network, type, number, formattedNumber, expirationMonth,
expirationYear, cvv, cardholderName and status. A single record is an object;
multiple records are an array. number is unformatted; formattedNumber is for display.
The status text is “Test card only,” not an account or authorization status.
CSV uses the headers Card type, Card number, Expiration month, Expiration year, CVV/CVC, Cardholder name and Status. Keep the numeric-looking values as text when importing them, particularly leading-zero security codes and long identifiers. The Visa round-trip exercise demonstrates that failure directly.
Reuse the fixed checks alongside random output
Extract the shared format-check bundle and run:
node --test card-validation.test.mjs luhn.test.mjs
These tests use the same profile that supplies this generator’s rules and the number validator. They verify generator prefix endpoints and output lengths, then exercise additional fixed controls that the generator will not emit, including wrong checksums, unsupported lengths and embedded letters.
Use the Amex transition cases when switching brands breaks a security-code field. Use the Mastercard boundary cases when a range endpoint is misclassified. These focused exercises produce a clearer failure than generating a large random batch and hoping the relevant condition appears.
Run a local check with a known outcome
The random generator is useful for input variation. This fixed check demonstrates a specific difference: a passing number and a one-digit typo have the same brand, but opposite checksum results.
Extract the validation bundle above and run node quickstart.mjs with Node.js 22 or later.
No API key, payment SDK or network request is needed. The command prints both results and
exits unsuccessfully if an assertion fails.
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { inspectCard } from './card-validation.mjs';
const read = name => JSON.parse(readFileSync(new URL(name, import.meta.url), 'utf8'));
const profile = read('card-profiles.json');
const cases = read('card-validation-cases.json').cases;
const original = cases.find(row => row.id === 'visa-4-16').input;
const typo = original.slice(0, -1) + ((Number(original.at(-1)) + 1) % 10);
for (const [label, input, expected] of [
['original', original, 'pass'],
['one-digit typo', typo, 'fail'],
]) {
const result = inspectCard(input, profile);
assert.equal(result.status, 'ok');
assert.equal(result.brand, 'visa');
assert.equal(result.lengthState, 'supported');
assert.equal(result.checksum, expected);
console.log(JSON.stringify({label, brand: result.brand, checksum: result.checksum}));
}Run node --test quickstart.test.mjs to exercise the same example in the shared suite.
Keep random values out of the acceptance decision
A generated number is useful because its shape is controlled. It does not establish an issued card, a usable security code, an issuer country or available funds. Save the synthetic input that reproduces a bug, record the expected local result and retest that case after a fix. Test gateway outcomes separately with its documented sandbox inputs.