Test card only
Credit Card Number Generator
Generate dummy card details for development and QA. Nothing is stored or sent to a server.
This Visa card generator produces Luhn-valid test Visa card numbers on the 4 prefix for
payment form validation, checkout QA, and automated test fixtures. What follows is the part
most tools in this category leave out: Visa’s actual format rules, why the 13/16/19-digit
question breaks so many checkout forms, and where these numbers stop being useful.
Visa card number format
| Property | Value |
|---|---|
| Major Industry Identifier (first digit) | 4 |
| IIN / BIN range | 4 — every Visa number begins with it |
| Standard length | 16 digits |
| Legacy length | 13 digits (older cards, still valid) |
| Extended length | 19 digits (some Visa Electron and co-branded products) |
| Check digit | Luhn (mod 10) |
| Security code name | CVV2 |
| Security code length | 3 digits |
The 13/16/19-digit problem
A common validation bug is hard-coding Visa numbers to 16 digits. ISO/IEC 7812 permits a primary account number of up to 19 digits, and Visa has issued 13-digit numbers historically and 19-digit numbers on some products. If your form rejects anything that is not 16 digits, it will reject cards that are perfectly valid — and the cardholder has no way to work around it.
Test all three lengths. These are Luhn-valid and safe to paste into a test form:
13 digits 4222 2222 2222 2
16 digits 4539 1488 0343 6467
19 digits 4532 0151 1283 0366 187
The generator above emits the 16-digit form, which is what nearly every issued Visa card uses. For the two rarer lengths, use the numbers above, or construct your own — the checksum arithmetic is identical at any length.
Visa product types and their BIN ranges
Visa is a family of products, not one card, and their BIN characteristics differ:
- Visa Classic / Credit — begins with
4, 16 digits, the default case - Visa Debit — also begins with
4; nothing in the number distinguishes it from credit - Visa Electron — issued on
4026,417500,4405,4508,4844,4913, and4917 - Visa Purchasing / Corporate — separate commercial BIN ranges
- V PAY — a Europe-only chip-and-PIN product, also on
4
You cannot tell whether a Visa number is credit or debit from the number alone. That information lives in the issuer’s BIN table, not in the digits. If your routing logic needs to know — to apply different interchange handling, or to block credit funding on a payout flow — you need a BIN lookup service. See the BIN and IIN guide for how those tables are structured, and the BIN lookup tool when it ships.
How this Visa card generator builds test numbers
Three steps, all in your browser:
- Prefix. The number starts with
4, Visa’s entire network prefix. - Account body. The digits between the prefix and the final position are drawn from
crypto.getRandomValues(), the browser’s cryptographically secure random source. - Check digit. The last digit is computed so the whole number satisfies Luhn.
Worked through for a real Visa payload:
Partial number: 4539 1488 0343 646_
Step 1 — Double every second digit, from the rightmost payload digit leftwards:
4 5 3 9 1 4 8 8 0 3 4 3 6 4 6
×2 ×2 ×2 ×2 ×2 ×2 ×2 ×2
8 5 6 9 2 4 16 8 0 3 8 3 12 4 12
Step 2 — Subtract 9 from any result above 9:
8 5 6 9 2 4 7 8 0 3 8 3 3 4 3
Step 3 — Sum: 8+5+6+9+2+4+7+8+0+3+8+3+3+4+3 = 73
Step 4 — Check digit = (10 − (73 mod 10)) mod 10 = (10 − 3) mod 10 = 7
Result: 4539 1488 0343 6467
The full Luhn walkthrough lives in the guides.
Testing scenarios specific to Visa
These are the cases a Visa card generator is actually good for — each one exercises your own code rather than a processor’s.
Length flexibility. Feed the form all three lengths above and confirm each is accepted. This is the single highest-value test on this page.
Brand detection on the first keystroke. The Visa mark should appear as soon as the user
types 4, not on blur and not after 16 digits. Visa is the one network where a single digit
is enough to decide.
CVV2 field length. Three digits for Visa, four for American Express. If your CVV field
is a fixed maxlength=3, Amex breaks; if it is fixed at 4, Visa accepts a code that is too
long. The field has to react to the detected brand.
Input mask. Visa groups as 4444 4444 4444 4444 at 16 digits. At 19 the grouping runs
4444 4444 4444 4444 444, and at 13 it is 4444 4444 4444 4 — masks that assume four
even groups mangle both.
Luhn rejection. Change the last digit of any generated number and confirm the form rejects it. A form that accepts both is not running the checksum.
BIN routing. If Visa traffic goes to a particular acquirer, generate a batch and confirm
the routing table picks it up on the leading 4.
A brand-detection regex that handles every valid Visa length:
// Visa brand detection — matches all three valid Visa lengths
const VISA = /^4\d{12}(\d{3})?(\d{3})?$/;
const normalise = value => value.replace(/\D/g, '');
VISA.test(normalise('4222 2222 2222 2')); // 13-digit → true
VISA.test(normalise('4539 1488 0343 6467')); // 16-digit → true
VISA.test(normalise('4532 0151 1283 0366 187')); // 19-digit → true
VISA.test(normalise('4539 1488 0343 646')); // 15-digit → false
VISA.test(normalise('5425 2334 3010 9903')); // Mastercard → false
The two optional three-digit groups are what admit exactly 13, 16, and 19 while rejecting everything between. Strip separators before testing — the pattern matches digits only. Note that this checks shape, not the checksum; run both.
Visa’s own test card numbers
Visa publishes test card numbers for merchants and processors through its developer programme, and every major gateway ships its own Visa test numbers. Those numbers are registered in the processor’s sandbox and return genuine authorisation responses. Ours do not.
| This generator | Gateway sandbox card | |
|---|---|---|
| Passes client-side Luhn check | Yes | Yes |
| Triggers Visa brand detection | Yes | Yes |
| Unlimited unique numbers | Yes | No — a handful of fixed numbers |
| Returns an authorisation response | No | Yes |
| Triggers specific decline codes | No | Yes |
| Works with 3-D Secure flows | No | Yes |
The split is clean: use a Visa card generator like this one while you are testing your own code, and switch to the gateway’s numbers the moment the processor’s behaviour is what you are testing. Stripe and PayPal both publish full tables, and we collect the equivalents on the test card numbers reference.
Visa card anatomy
Taking 4539 1488 0343 6467 apart:
4 5 3 9 1 4 8 8 0 3 4 3 6 4 6 7
└──────┬────────┘ └───────────┬────────────┘ └┬┘
│ │ │
│ │ └── Check digit (Luhn)
│ └──────────────────── Individual Account Identifier
└───────────────────────────────────────────── IIN / BIN (first 6–8 digits)
↑
└─ MII: 4 = banking and financial, and Visa's network prefix
The leading 4 does double duty — it is both the Major Industry Identifier for banking and
finance and Visa’s entire scheme prefix. The next five digits complete the six-digit IIN
identifying the issuing bank, though under ISO/IEC 7812-1:2017 that field is migrating to
eight digits, so lookup code should not assume six. The nine digits after it are the account
identifier, and the final 7 is the Luhn check digit computed above.
For a network-by-network comparison, the all-network credit card generator carries the full format table; Mastercard, American Express, and Troy have their own pages, and the tool directory lists everything else. The FAQ covers what a Luhn-valid number does and does not prove.