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.
| Network | Generator output | Validator profile |
|---|---|---|
| American Express | 15 | 15 |
| Diners Club | 14 | 14, 16, 19 |
| Discover | 16 | 16, 19 |
| JCB | 16 | 16, 17, 18, 19 |
| Maestro | 16, 19 | 12, 13, 14, 15, 16, 17, 18, 19 |
| Mastercard | 16 | 16 |
| Troy | 16 | 16 |
| UnionPay | 16, 19 | 16, 17, 18, 19 |
| Visa | 16 | 13, 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
| Fixture | Expected local length result | Why it is useful |
|---|---|---|
| JCB, 17 and 18 digits | Supported | Catches a mistaken [16, 19] set |
| Diners, 14, 16 and 19 digits | Supported | Exercises each member of the configured set |
| Diners, 15, 17 and 18 digits | Unsupported | Catches a loose continuous-range check |
| A 20-digit value | Unsupported; checksum not evaluated by this tool | Keeps analysis within the declared envelope |
| Unknown prefix with a passing checksum | Length unresolved by brand | Avoids 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.