Compare the tool output with the checking profile

A generator output, a local validation rule and a provider’s acceptance contract are three different scopes. This table describes the first two for ccgenerator.org. It is rendered from the JSON configuration used by the tools rather than maintained as another independent list of numbers.

NetworkGenerator outputValidator profile
American Express1515
Diners Club1414, 16, 19
Discover1616, 19
JCB1616, 17, 18, 19
Maestro16, 1912, 13, 14, 15, 16, 17, 18, 19
Mastercard1616
Troy1616
UnionPay16, 1916, 17, 18, 19
Visa1613, 16, 19

The all-network generator has no per-length selector. For a chosen prefix and total length, use the prefix generator, or use the fixed cases in the downloadable bundle below. A longer fixture need not be something the network-specific generator emits randomly.

Why the sets must be explicit

This profile supports JCB lengths 16, 17, 18 and 19. It supports Diners lengths 14, 16 and 19. Writing 14–19 for Diners would incorrectly imply that the intervening lengths are part of this same profile.

Cybersource’s identification reference documents JCB at 16–19 and a classic 14-digit Diners profile. Braintree’s configuration includes Diners at 14, 16 and 19. These references illustrate why you should name the profile you implement, rather than presenting one table as a complete worldwide guarantee.

The validator now supports the additional JCB and Diners cases listed above. Its 12–19-digit checksum-analysis envelope is a local tool limit, not a statement that a checksum alone makes every input in that interval a valid card number.

Use valid checksums to isolate length failures

FixtureExpected local length resultWhy it is useful
JCB, 17 and 18 digitsSupportedCatches a mistaken [16, 19] set
Diners, 14, 16 and 19 digitsSupportedExercises each member of the configured set
Diners, 15, 17 and 18 digitsUnsupportedCatches a loose continuous-range check
A 20-digit valueUnsupported; checksum not evaluated by this toolKeeps analysis within the declared envelope
Unknown prefix with a passing checksumLength unresolved by brandAvoids inventing a brand rule from the digit count

The complete-length controls in the download use computed check digits. For example, a 17-digit Diners control can pass the arithmetic check while failing this length profile. That isolates the condition under test instead of mixing a length error with a typo.

Extract the shared length and validation fixtures and run node --test card-validation.test.mjs. The same inspection code runs in the interactive validator.

Count digits separately from display characters

A 19-digit string displayed in groups of four contains four additional spaces. An input component that caps the display at nineteen characters can discard the last four digits before your length check sees them. Test paste, autofill and editing, then compare the normalized value with the original synthetic fixture.

Keep digit strings as text throughout serialization. The Visa input exercise demonstrates precision loss and leading-zero handling. A database or parser may reject, truncate or coerce oversized values depending on its configuration; assert the returned value instead of assuming a particular failure.

Group according to the formatting profile

Classic Diners formatting uses 4-6-4; Amex uses 4-6-5. That does not mean every fourteen- or fifteen-digit identifier should use those groups. The Diners caret fixtures test editing a particular mask, and the Amex transition fixtures test changing brand rules in the same form session.

Length support also does not select a payment route or tell you whether a security code is required. Use the brand-detection guide for candidate handling, then apply your provider’s documented input requirements separately.

Frequently Asked Questions

Why do the generator and validator allow different lengths?
The generator supplies a practical subset of format fixtures. The validator’s documented profile includes additional lengths. Neither list establishes what a particular merchant or processor accepts.
Does a 19-digit number require a 19-character input limit?
Not when separators are displayed. Four spaces make a 19-digit number occupy 23 characters. Test the actual component so a mask or maxlength does not remove digits before validation.
Should every length between the shortest and longest be accepted?
No. This site’s Diners profile uses 14, 16 and 19, so 15, 17 and 18 are outside it. Use explicit sets rather than turning a non-contiguous list into a continuous range.
Does number length determine display grouping?
No. The selected brand and the component’s formatting profile matter too. The classic Diners fixture uses 4-6-4 and Amex uses 4-6-5; length alone is not a universal formatting rule.