Credit Card Number Generator
Generate reproducible Luhn-valid card-shaped fixtures for form testing, with synthetic prefixes and optional CVV or expiry fields.| # | Card shape | Number | Prefix | Digits | Luhn | CVV / CVC | Expiry | Copy |
|---|---|---|---|---|---|---|---|---|
| Correct the settings to restore generated rows. | ||||||||
| {{ row.index }} | {{ row.network }} | {{ row.display }} | {{ row.prefix }} | {{ row.length }} | {{ row.luhn_valid ? 'Valid' : 'Invalid' }} | {{ row.cvv || '—' }} | {{ row.expiry || '—' }} | |
| Setting | Value | QA meaning | Copy |
|---|---|---|---|
| {{ row.label }} | {{ row.value }} | {{ row.note }} |
Checkout forms need card-shaped test data long before a payment processor is involved. Length checks, pasted separators, masking, security-code fields, and expiry inputs can all fail inside the interface itself. Synthetic numbers let those paths be tested without copying a customer’s Primary Account Number (PAN) into a fixture, screenshot, or bug report.
A PAN has a recognizable structure. Its leading digits form the Issuer Identification Number (IIN), still often called a BIN. The middle is an account-identifying body, and the final digit is a Luhn check digit. Passing that checksum catches many typing errors, but it says nothing about whether an account exists, a card was issued, or a processor will accept the number.
| Part | What it controls in form testing | What it cannot prove |
|---|---|---|
| IIN or BIN prefix | Network-shaped branching, grouping, and expected length | Issuer identity or account ownership |
| Account body | Field capacity, uniqueness, masking, and fixture variety | A usable payment credential |
| Luhn check digit | Whether the completed digit string satisfies the checksum | Authorization, balance, fraud status, or processor behavior |
Realistic shape is useful for front-end quality assurance, but processor scenarios need provider-published test values or tokens. Approval, decline, 3-D Secure, refund, dispute, and webhook flows depend on the sandbox provider, not on a generated Luhn-valid number.
Treat every generated row as visible test data. A synthetic value may still resemble a live PAN, and masking only changes what is shown in the preview. The complete generated number remains available to copy and export, so keep these rows in test systems and never replace a seed or prefix with customer information.
How to Use This Tool:
Choose the form branch you need to exercise, then make the fixture reproducible before sharing it with another tester.
- Select a QA profile or choose a Card shape, then set Quantity. The profile supplies practical defaults, but it does not create an official processor scenario.
- Enter a Custom BIN / IIN only when a known synthetic prefix is part of the test. With Enforce profile prefix on, a prefix that does not overlap the selected card shape is replaced and reported as a warning.
- Choose the visible grouping and optional synthetic CVV/CVC or expiry fields. Use Length override only for deliberate boundary testing; zero keeps the selected profile’s default length.
- Set a Replay seed from 1 to 64 characters. Reuse that seed with every other setting to reproduce the same rows.
- Generate the batch and check the Luhn count, prefix strategy, and target length before copying a number into a local test.
Interpreting Results:
A complete batch should report every row as Luhn-valid. The card-shape label describes the practical prefix and default-length profile used for generation; it is not an issuer lookup. If the prefix strategy says that a bundled profile fallback was used, the custom prefix was not applied.
- Compare Target length with the field branch you intended to test.
- Keep the replay seed and settings together when a bug must be reproduced.
- Use the displayed masking only for presentation checks. Copy and machine exports retain the complete synthetic number.
- Switch to provider-published test cards or tokens before testing processor outcomes.
Technical Details:
A generated row is assembled from a selected prefix, a seeded sequence of body digits, and one checksum digit. The pseudo-random sequence is deterministic rather than cryptographically secure: the same seed, row number, and settings produce the same fixture.
Formula Core
The Luhn check digit is the value that makes the transformed digit sum divisible by 10. Starting at the rightmost digit of the unfinished number, every other digit is doubled; products above 9 are reduced by 9.
Here, S is the sum after alternating digits are transformed and c is the appended check digit. Validation repeats the alternating transformation over the complete number; a remainder of zero means the number passes Luhn.
Rule Core
- Choose a custom prefix when it is allowed by the selected profile, otherwise choose one value from the profile’s bundled prefix ranges.
- Fill the remaining body positions from the seeded sequence, leaving one final position for the check digit.
- Append the Luhn digit and reject a duplicate when unique-batch mode is on.
- Derive optional CVV/CVC digits and an inclusive whole-month expiry offset from the same seeded row sequence.
- Apply grouping and preview masking after the raw number has been created.
| Card shape | Bundled leading values | Default digits |
|---|---|---|
| Visa-shaped | 4 | 16 |
| American Express-shaped | 34 or 37 | 15 |
| Mastercard-shaped | 51 to 55 or 2221 to 2720 | 16 |
| Discover-shaped | 6011, 622126 to 622925, 644 to 649, or 65 | 16 |
| Diners Club-shaped | 300 to 305, 36, or 38 to 39 | 14 |
| JCB-shaped | 3528 to 3589 | 16 |
| Maestro-shaped | 50 or 56 to 69 | 16 |
| UnionPay-shaped | 62 | 16 |
These profiles are practical and intentionally non-exhaustive. They control fixture shape only and can become outdated as payment numbering ranges change.
| Setting | Accepted rule | Why it matters |
|---|---|---|
| Quantity | 1 to 100 rows | A unique request is rejected when the remaining body space is too small. |
| Length override | 0, or 12 to 24 digits | The prefix must still leave room for one Luhn digit. |
| Custom prefix | Digits only, at most 23 digits | Profile enforcement may replace a non-overlapping prefix. |
| Expiry window | 1 to 120 months ahead, inclusive | The latest offset must be at least the earliest. |
| Replay seed | 1 to 64 characters | Every setting, not the seed alone, must match for identical rows. |
Responsible Use:
Use these values only for local form QA, fixtures, demonstrations, and screenshots. Do not submit them to live payment endpoints, represent them as official sandbox cards, or use a real PAN, customer identifier, or production BIN as input.
- Luhn validity is a format check, not evidence of issuance or authorization.
- Generated CVV/CVC and expiry values have no processor meaning.
- A masked preview does not redact copied or exported rows.
- Provider-specific behavior must be tested with that provider’s documented test data.
Worked Examples:
Repeatable checkout fixture
A Visa-shaped 16-digit batch with prefix 411111 and seed golden-visa can be kept beside a form test. Reusing the same quantity and every advanced setting recreates the same rows, while changing only the display format alters grouping rather than the underlying digits.
Prefix mismatch
If an American Express-shaped profile is paired with a custom prefix that does not overlap 34 or 37 while profile enforcement is on, generation uses a bundled profile prefix instead. The prefix warning is the cue to correct the test setup before copying the row.
References:
- ISO/IEC 7812 Registration Authority IIN information, American Bankers Association, September 2017.
- Computer for verifying numbers, United States Patent 2,950,048, August 23, 1960.
- Test card numbers, Stripe Documentation.