Credit Card Number Generator
Generate dummy Luhn-valid credit card numbers for testing and QA.
Written by Anil Gautam · Updated
How are the dummy card numbers built?
Each number starts with one of three six-digit prefixes for the chosen brand, several of them taken from widely published test numbers such as 4111 1111 1111 1111. Mastercard output includes the 2-series prefix 222100, useful for finding validators that still accept only numbers starting 51 to 55. The middle digits come from the browser's cryptographic random generator, and the last digit is a Luhn check digit. Lengths follow each brand: 16 digits for Visa, Mastercard, Discover and JCB, 15 for American Express and 14 for Diners Club.
Every record also gets a random CVV (four digits for American Express, three for the rest), an expiry month from 01 to 12 with a year two to six years after the current one, which is 2028 to 2032 when generated in 2026, and a name of the form TEST USER 01. The Country menu only fills the country field, and the same prefixes are used whatever country you pick.
How does the Luhn check validate a card number?
Start from the rightmost digit and double every second digit moving left. When doubling gives a two-digit result, subtract 9, so 7 becomes 14 and then 5. Add everything up, and the number is valid when the total is a multiple of 10. For 4111 1111 1111 1111, the eight doubled positions (seven 1s and the leading 4) become seven 2s and an 8, which sum to 22, and the eight undoubled 1s add 8, for a total of 30. The generator picks the final digit that makes the total a multiple of 10.
Luhn catches any single wrong digit and most swaps of neighboring digits. It misses a swap of 09 and 90, which give the same total, so a form that relies on Luhn alone will accept that typo.
Where will these test numbers work?
These numbers suit checks that run in your own code: form validation, brand detection from the leading digits, input masks, display layouts and seed data for a test database. The formatted versions follow the grouping printed on real cards, 4-4-4-4 for most brands, 4-6-5 for American Express and 4-6-4 for Diners Club. Payment gateway sandboxes usually accept only the exact test card numbers they publish, and only the first six digits here match those lists, so a sandbox will normally refuse these. Take numbers for test payments from the gateway's own list.
JSON output carries every field, including the formatted number and a testOnly flag set to true. CSV keeps the plain digits and drops the formatted copy, and plain text gives one line per card with brand, number, expiry, CVV and name. Download saves the file as dummy-credit-cards with a .json, .csv or .txt extension. If you also need names, emails and phone numbers in the same rows, the Fake Data Generator has a Visa-style test card field.