Skip to main content
CC

Credit Card Number Generator

Generate Luhn-valid test card numbers for Visa, Mastercard, Amex and Discover — for software testing only, never real transactions.

Did you like the tool? Thanks!
Share:
Test data only — not real card numbers. Every number below is mathematically valid (it passes the Luhn checksum) but is not a real, active financial account. These numbers are not linked to any bank, cardholder or real balance, and cannot be used to buy anything. They exist purely so developers and QA teams can test payment-integration code — the same purpose as the published test card numbers from Stripe, PayPal and other payment processors.


    

For software testing and QA of payment-integration code only. Not real financial account numbers.

How to Use Credit Card Number Generator

Pick a card type and how many numbers you need (1-20), then press Generate. Every number passes the Luhn checksum used by real card networks and has the correct length and prefix for its issuer, so it behaves like a real card number to any client-side validation your payment form performs. These numbers are not linked to any bank account, cannot be charged, and are for testing payment-integration code only — see the disclaimer above the generator.

About Credit Card Number Generator

Almost every payment card number in the world — Visa, Mastercard, Amex, Discover, and more — is built so that a simple checksum called the Luhn algorithm can catch the vast majority of accidental typos before a transaction is even attempted. This tool generates numbers that pass that same checksum with correct issuer-specific prefixes and lengths, which makes them useful for exercising the client-side validation logic of a checkout form, a card-number input mask, or a payment SDK's format-checking step — without ever touching a real account, a real payment network, or real money. It is important to be completely clear about what these numbers are and are not. They are not real, active card numbers. They are not linked to any bank, any cardholder, or any actual balance. They cannot be used to make a genuine purchase anywhere, because passing the Luhn checksum only proves a number is structurally well-formed — it says nothing about whether that number corresponds to an account that exists, has funds, or was ever issued by a bank at all. Every real payment processor checks far more than the Luhn digit before authorising a charge: the card must exist in the issuing bank's systems, have a valid expiry date and CVV on file, have sufficient funds or credit, and pass fraud-detection checks. A Luhn-valid number generated by a tool like this one will be rejected by any real payment gateway the moment it reaches an actual authorisation step, precisely because it was never issued to anyone. This is exactly the same category of tool as the official test card numbers published by Stripe (numbers like 4242 4242 4242 4242), PayPal, Braintree, and virtually every other payment processor for their own sandbox/test environments — a Luhn-valid, correctly-formatted number that lets developers build and test the flow of a payment form (input validation, card-type detection, formatting-as-you-type, error states) without needing a real card or moving real money during development. The numbers generated here work the same way for testing your own front-end validation logic, but unlike a processor's official test numbers, they will not be accepted by that specific processor's sandbox environment, since each processor only recognises its own designated test numbers for actual sandbox transactions — for testing against a real payment gateway's sandbox, always use that gateway's own published test card numbers instead of a generic generator like this one. Using these — or any card number — to attempt a real purchase, to probe a live payment system, or to represent them as real payment information to another person or service is both dishonest and, depending on jurisdiction and intent, potentially illegal. This tool exists solely to help developers build and test code; it must never be used or represented as a way to obtain goods, services, or credit.

Details & Tips

How the Luhn checksum works, in the exact form this tool implements it: starting from the rightmost digit of the number and moving left, every second digit is doubled; if doubling produces a two-digit result, its digits are added together (equivalently, 9 is subtracted from it). All digits — doubled-and-reduced ones and untouched ones alike — are then summed, and a valid card number's total is always a multiple of 10. To generate a valid number, this tool works in the opposite direction: it builds every digit except the last one (issuer prefix plus random filler digits), runs the same doubling process across those digits, and calculates whichever final digit brings the total to a multiple of 10 — that becomes the check digit appended at the end. Issuer prefixes and lengths used by this generator, matching real-world card numbering rules (IIN/BIN ranges) so the output looks structurally authentic to any front-end card-type detector: Visa numbers start with `4` and are 16 digits long. Mastercard numbers start with `51` through `55`, or with a four-digit prefix between `2221` and `2720` (the newer range Mastercard introduced once the classic range began running out), and are also 16 digits. American Express numbers start with `34` or `37` and are 15 digits — one shorter than the others, which is itself a common source of bugs in card-input forms that hard-code a 16-digit assumption, making Amex numbers particularly useful test cases. Discover numbers start with `6011` or `65` and are 16 digits. What this tool is genuinely useful for: confirming your checkout form's Luhn-validation step correctly accepts well-formed numbers and correctly rejects malformed ones, checking that your card-type auto-detection logic (the code that shows a Visa versus Mastercard icon as someone types) identifies each prefix correctly, verifying input masks and formatting-as-you-type behaviour across different card lengths (especially the 15-digit Amex case), and populating demo or screenshot data without using anyone's real information. What this tool is never appropriate for: attempting any real purchase or transaction, testing against a live (non-sandbox) payment processor, representing a generated number as a genuine payment method to any person or system, or any use where the recipient is led to believe the number represents real funds. If you need numbers that work against a specific payment gateway's sandbox environment (Stripe, PayPal, Braintree, Square, etc.), use that gateway's own official published test numbers — each processor only recognises its own designated test values in its sandbox, so a generic Luhn-valid number from this tool will simply be declined there, exactly as it would be declined anywhere else in the real world.

Frequently Asked Questions

Are these real credit card numbers?
No. They are mathematically valid — they pass the Luhn checksum every real card number uses — but they are not linked to any bank, any cardholder, or any real account. They cannot be used to purchase anything.
Can I use these numbers to buy something online?
No, and you should not try. These numbers were never issued by any bank, so any real payment processor will decline them at the authorisation stage. This tool exists solely to help developers test payment-form code, not to obtain goods or services.
What is the Luhn algorithm?
A checksum formula used by essentially all card networks to catch accidental typos: doubling every second digit from the right, reducing any two-digit results by summing their digits, and requiring the total to be a multiple of 10. It confirms a number is well-formed, not that it belongs to a real account.
Will these numbers work in Stripe's or PayPal's test/sandbox mode?
Not reliably. Each payment processor only recognises its own specific published test numbers in its sandbox environment (e.g. Stripe's 4242 4242 4242 4242). Use the processor's own official test numbers for sandbox testing — this generator is for testing your own front-end validation logic, not a specific gateway's sandbox.
Why does the Amex option generate 15 digits instead of 16?
That matches the real American Express numbering standard — Amex cards are genuinely 15 digits, one shorter than Visa, Mastercard, and Discover. It is a deliberately useful test case for catching forms that incorrectly assume every card number is 16 digits.
Is it illegal to use this tool?
Generating and using these numbers to test your own software is not illegal. Using them, or any card number, to attempt a real transaction, represent them as genuine payment information, or defraud anyone would be — this tool is provided strictly for legitimate software testing and must not be used otherwise.
How does the tool decide which prefix to use for each card type?
It follows the published IIN/BIN numbering ranges each network actually uses: 4 for Visa; 51-55 or 2221-2720 for Mastercard; 34 or 37 for Amex; 6011 or 65 for Discover — so the generated numbers look structurally authentic to card-type detection logic.
Can these numbers have a real CVV or expiry date associated with them?
No — this tool only generates the primary account number itself. There is no real CVV, expiry date, or cardholder record behind any of these numbers because they were never issued to begin with; any CVV/expiry you pair them with for testing is equally fictional.
Why would a developer need fake card numbers at all?
To test checkout flows, validation rules, formatting-as-you-type, and card-type detection without needing a real card or risking a real charge during development — the same reason every major payment processor publishes their own official test numbers for sandbox use.
Does generating a number here ever contact a payment network?
No. Generation is entirely local — the Luhn checksum is calculated with plain JavaScript in your browser. No network request, card network, or bank is involved at any point.
Can I generate more than 20 numbers at once?
The tool caps bulk generation at 20 per batch to keep the output easy to review; run Generate again for additional batches if you need more.

Part of These Collections

Also Available As

credit card generator, test card number generator, luhn algorithm generator, fake credit card number for testing, visa test number, mastercard test number

Found a Problem?

Let us know if something with Credit Card Number Generator isn't working as expected.

Thanks — we'll take a look.