Choose a card type
How many?
1

Test data only. Local fixtures do not issue cards, verify accounts or provide payment authorization. Use them only in authorized tests. Why?

VisaTEST CARD
•••• •••• •••• ••••
Cardholder—
ExpiresMM/YY
CVV•••
  • Generated fields are not uploaded
  • Randomly generated in your browser
  • Every number passes the Luhn check

Test Visa input without losing a digit

Use this page to check paste handling, length policy and storage precision. The tool starts on Visa and produces 16-digit numbers. It does not generate the 13- or 19-digit fixtures below; those are fixed local test inputs supplied separately so that each run covers the same edge cases.

Start with one generated card for a manual form check. For a regression test, save the fixture files below: changing the quantity or pressing Generate creates fresh values, which is useful for variety but does not reproduce a particular failure.

Visa card number format

The parser in this example accepts a leading 4 and an explicit list of lengths. Its default profile is [16, 19]; a separate case opts into a legacy 13-digit input. This is a sample application’s policy, not a rule that every gateway accepts those lengths. Cybersource’s card identification reference describes Visa numbers up to 19 digits. Confirm the actual profile with your processor and SDK before adopting a local allowlist. The Visa format guide provides the background; this page concentrates on what happens to the input in your code.

FixtureWhat it isolatesExpected result in this example
4539148803436467Ordinary 16-digit inputPreserve the exact string
4539 1488 0343 6467Paste with ordinary spacesRemove spaces, retain all digits
The same groups with nonbreaking spacesText copied from a formatted documentNormalize the documented separator
4539-1488-0343-6467Hyphen-separated pasteRemove hyphens without changing the number
453201511283036618719-digit storage boundaryPreserve all 19 digits through JSON
4222222222222Legacy length configurationReject under [16, 19]; accept under [13, 16, 19]
4539x148803436467An unexpected letterReject; do not silently erase the letter
453914880343646Truncation to 15 digitsReject under either profile

“Accept” here means the input passed this parser’s shape rules. The parser does not run Luhn, identify an issuing account or submit a payment. Test checksum handling separately with the card validator.

Run the paste and round-trip checks

Download Visa input fixtures (JSON) and the runnable Visa checks into the same directory. With Node.js installed, run:

node --test visa-input.test.mjs

The file runs ten input cases plus a precision check without installing a package or calling a service. This excerpt is read directly from that downloadable file; the file also contains its imports, fixture loader and assertions.

function parseVisaInput(value, acceptedLengths) {
  if (typeof value !== 'string') return null;
  // Accept documented separators, not arbitrary non-digit characters.
  const digits = value.replace(/[ \u00a0-]/g, '');
  if (!/^4\d+$/.test(digits)) return null;
  return acceptedLengths.includes(digits.length) ? digits : null;
}

// The sample profile is a choice: align it with your processor and SDK.
const acceptedLengths = [16, 19];
const number = parseVisaInput('4532 0151 1283 0366 187', acceptedLengths);
const restored = JSON.parse(JSON.stringify({ number }));
assert.equal(restored.number, '4532015112830366187');

To test your application, replace parseVisaInput in the downloaded runner with an import of your own normalization function and keep the fixture expectations. A passing sample runner demonstrates the contract; it does not prove that your checkout implements it.

The precision failure to reproduce

A card number is an identifier, even when it contains only digits. The 19-digit fixture exceeds JavaScript’s exact integer range: converting it to Number and back changes its value. The JavaScript numeric limit explains why this is a data-type problem, not a checksum problem.

Keep the number, expiry components and CVV as strings when adapting the generator’s JSON. For CSV imports, set the number and CVV columns to text before importing; quoting a CSV cell alone does not force a spreadsheet to preserve its type. The bulk generator documents the export schemas for larger sets.

Manual checkout exercise

  1. Paste the 19-digit fixture into your development form, then blur and refocus the field. Compare the unformatted value before and after: neither a mask nor maxlength should silently remove the final three digits.
  2. Paste the same input with spaces. Check the submitted test payload, not only the visible mask; a correct-looking field can still serialize the wrong value.
  3. Insert x between digit groups. Confirm your chosen validation policy reports invalid input instead of quietly constructing a different number.
  4. Save the fixture through your application’s local test persistence layer, reload it and compare the entire string. A test that compares only the last four digits misses this bug.

For an input-length defect, record the raw pasted string, configured length profile, normalized value and round-trip value in the failing test. This distinguishes an input-mask problem from numeric coercion further down the pipeline.

When the test crosses into a payment gateway

Use provider fixtures for approval, decline and authentication responses. A generated Visa number does not stand in for a registered sandbox card. The gateway test-card reference keeps those provider-specific cases separate from these local input tests.

If the defect appears only after switching brands, use the Amex transition tests. If it is a prefix boundary rather than a length problem, use the Mastercard range tests.

Frequently Asked Questions

Does the generator produce 19-digit Visa numbers?
No. The tool currently generates 16-digit Visa numbers. The downloadable input fixture set separately supplies a 19-digit case and a legacy 13-digit case so you can test an explicit length profile.
Should my form accept every length listed on this page?
Use the lengths supported by your processor and SDK. The example defaults to 16 and 19 digits and tests an explicit opt-in for 13. It demonstrates a configurable input policy, not universal gateway acceptance.
Why store a card number as a string?
A 19-digit value exceeds JavaScript’s safe integer range. Converting it to Number can change the digits. Strings also preserve leading zeros in fields such as security codes.
Does the sample parser check Luhn?
No. It checks input type, documented separators, the leading 4 and the configured lengths. Add a separate checksum test; neither check establishes an account or payment approval.