Credit Card Number Formatter
EverydayFormat raw card numbers into XXXX XXXX XXXX XXXX with masking options. Supports Visa, Mastercard, Amex, and Diners — in-browser, no data uploaded anywhere.
What is a Card Number?
The Credit Card Number Formatter takes raw payment card digit sequences — entered with or without spaces, hyphens, or other separators — and outputs them in the standard grouped display format used on physical cards, receipts, and payment interfaces. It also applies masking to produce partially or fully anonymised display strings for UI mockups, reports, and developer documentation.
The most common format is XXXX XXXX XXXX XXXX — four groups of four digits separated by spaces, used by Visa, Mastercard, Discover, and India's RuPay network. American Express uses a different grouping: XXXX XXXXXX XXXXX (4-6-5), while Diners Club uses XXXX XXXXXX XXXX (4-6-4). The formatter auto-detects Amex and Diners from the leading digits, and defaults to 4-4-4-4 for everything else.
This tool is designed for:
- UI/UX mockups where placeholder card numbers need realistic formatting
- Developer testing with published test card numbers (e.g. 4111111111111111)
- Documentation where formatted card numbers illustrate form field behaviour
- Masking for receipts, transaction logs, and customer-facing displays showing only the last 4 digits
It is not designed for processing real cardholder data in a web tool. For Luhn algorithm validation and card network detection, use the Credit Card Validator.
All formatting is client-side. Your input is never transmitted to any server, stored, or logged. The page works offline once loaded.
How to use this Card Number calculator
- Paste card numbers into the "Card Number(s)" textarea — one per line. Input may be raw digits, hyphen-separated, or space-separated.
- Select the card type — use "Auto-detect" for most cases; override to "American Express" or "Diners Club" if auto-detect is producing the wrong grouping.
- Choose a masking option — "Show all digits" for full display, "Show last 4 only" for receipt-style, "Show first 6 and last 4" for BIN-preserving display, or "Mask all digits" for mockups.
- Review the output in the "Formatted Card Number(s)" panel — valid cards are formatted instantly; invalid inputs (wrong digit count) show an error per line.
- Click the copy button to copy all formatted card numbers to your clipboard.
- Validate with the Credit Card Validator if you also need to confirm Luhn checksum validity — use the Credit Card Validator as a follow-up step.
Formula & Methodology
Auto-detection rules (applied to raw digits before grouping): | Prefix pattern | Network | Format | Typical digit count | |---|---|---|---| |34,37| American Express | 4-6-5 | 15 | |300–305,36,38| Diners Club | 4-6-4 | 14 | | All others | Standard (Visa/MC/Discover/RuPay) | 4-4-4-4 | 16 | Grouping algorithm: - Standard (4-4-4-4): Split every 4 characters:digits.match(/.{1,4}/g)?.join(' ')- Amex (4-6-5): Fixed slices at positions 0–4, 4–10, 10–15 - Diners (4-6-4): Fixed slices at positions 0–4, 4–10, 10–14 Masking algorithm (applied before grouping, operating on raw digits): - last4:'#'.repeat(len - 4) + digits.slice(-4)- first6last4:digits.slice(0, 6) + '#'.repeat(len - 10) + digits.slice(-4)- full:'#'.repeat(len)Before/after example: | Raw Input | Card Type | Mask | Output | |---|---|---|---| |4111111111111111| Auto (Visa) | None |4111 1111 1111 1111| |4111111111111111| Auto (Visa) | Last 4 |#### #### #### 1111| |378282246310005| Auto (Amex) | None |3782 822463 10005| |378282246310005| Auto (Amex) | First 6 + Last 4 |378282 ###### 0005| |5500005555555559| Auto (MC) | First 6 + Last 4 |550000 ###### 5559| For background on the underlying term, see our glossary entry on Credit Card.
Frequently Asked Questions