Watermarked card preview
Create SVG or 1200 × 757 PNG test assets. Masking is on by default; every export includes the test watermark.
Expiry, security code and styling
Use synthetic inputs only. No real brand artwork is included. This image tool does not validate payment acceptance.
A card preview can appear correct with one short ASCII name and a 16-digit number while failing common layout cases. The examples above target those failures directly. The renderer preserves the name string, escapes it for SVG and groups the number according to the shared local profile.
Three previews worth comparing
| Example button | Expected visible result | Regression it catches |
|---|---|---|
| Amex + long name | 3782 822463 10005; full MARIA-ISABEL FERNÁNDEZ RODRÍGUEZ | Four-digit grouping everywhere; silent name truncation |
| Diners + RTL name | 3612 345678 9013; محمد عبدالله in the name area | Incorrect 14-digit grouping and right-to-left placement |
| 19-digit + Unicode | 6205 5000 0000 0000 004; Ayşe Öztürk | Last digits overflowing or disappearing; lossy name conversion |
The buttons reveal synthetic numbers explicitly. A fresh page starts masked, showing only the last four digits. Generic labels such as “Network A” are independent of number detection and contain no brand artwork. For actual prefix and checksum results, use the card validator.
Preserve the input before fitting it
Previously, the name input and renderer both stopped at 26 characters. That made a long-name test impossible: the test data was already damaged before the preview rendered. The current limit is 120 Unicode code points, reported as an error rather than silently truncating. Names above 22 characters are fitted into the name region. The JSON cases include accents, an ampersand and an Arabic name.
SVG text is escaped, so a value such as <script>alert(1)</script> remains text rather than markup. Right-to-left names receive an RTL direction and a separate text position. Visual shaping still depends on the browser and available fonts, so check your target browser with the actual script and name lengths you support.
The number formatter is the same function exercised by the automated examples:
export function previewNumber(input, reveal, profile) {
const normalized = normalizeInput(input);
if (normalized.status === 'empty') return '•••• •••• •••• ••••';
if (normalized.status !== 'ok' || normalized.digits.length > 19) throw new TypeError('Use up to 19 digits with spaces or hyphens; other characters are not removed');
const { digits } = normalized;
const brand = prefixCandidates(digits, profile).brand;
const groups = brand === 'amex' ? [4, 6, 5] : brand === 'diners' && digits.length === 14 ? [4, 6, 4] : [4, 4, 4, 4, 3];
const displayed = reveal === 'full' ? digits : '•'.repeat(Math.max(0, digits.length - 4)) + digits.slice(-4);
let offset = 0;
return groups.map(size => { const part = displayed.slice(offset, offset + size); offset += size; return part; }).filter(Boolean).join(' ');
}Spaces and hyphens are normalized according to the shared card-input rules. Letters, pasted line breaks and more than 19 digits cause a visible error and disable export until corrected. This renderer can display incomplete numeric input for design work; it does not require or claim a passing checksum.
Export checks
The SVG viewBox is 856 × 539.8; the PNG is 1200 × 757 pixels, with height rounded to the nearest pixel. The preview, SVG download and PNG use one rendering source. Both front and back include the repeated TEST CARD — NOT VALID watermark. Open Expiry, security code and styling to change those fields. The back displays the entered test code, including leading zeros.
Before saving a design baseline:
- Compare masked and revealed number states.
- Switch between front and back and confirm the watermark remains visible.
- Use a long name, an RTL name and a 19-digit number at a narrow viewport.
- Download both formats and confirm their text matches the preview. Font substitution in another SVG viewer may change glyph appearance; use PNG for a fixed raster result.
- Enter an invalid character and verify exports become unavailable rather than saving a stale image.
The identity generator supplies additional Unicode/address fixtures. The payment-form checklist explains which layout checks still need browser testing rather than a unit assertion.
Download the renderer and preview cases
and run node --test data-tools.test.mjs. Tests protect grouping, masking, name preservation, escaping, both-side watermarks and PNG dimensions. They do not replace a screenshot review of actual fonts and responsive layout.
Updated 8 November 2026: Amex/Diners grouping, long-name preservation, RTL placement and overlong-input errors now use the shared tested renderer.