oktools

Credit Card Generator

Generate fake credit card numbers for testing: dummy Visa, Mastercard, Amex, Discover, JCB and Diners Club numbers that pass the Luhn check and carry a real brand prefix, with an expiry, CVV and holder name, for exercising validation, brand detection and payment forms. None of them belongs to an account or can pay for anything.

Replaces the brand prefix. Digits only.
Test numbers only. These are dummy card numbers for development and QA: they pass Luhn validation and look like the brand they claim, but no account exists behind them and they cannot be used for real transactions. Payment gateway sandboxes expect their own published test cards instead.

Generated Cards (0)

#BrandCard NumberExpiryCVVHolderCountryCopy

How it works

Every number opens with a prefix drawn from the brand’s real issuer identification ranges: a 4 for Visa, 51–55 or 2221–2720 for Mastercard, 34 or 37 for American Express, 6011, 644–649 or 65 for Discover, 3528–3589 for JCB, and 300–305, 36 or 38–39 for Diners Club. One range is picked at random and then a value inside it, so a batch of Mastercard numbers mixes the older 5-series with the newer 2-series the way a real customer file does. Random digits then fill the number to one short of the brand’s length.

The final digit is not random. It is the Luhn check digit, chosen so the whole number passes the checksum every payment form runs before it contacts a gateway: working from the right, every second digit is doubled, nine is subtracted from any result above nine, the digits are added up, and the check digit is whatever brings the total to a multiple of ten. That is exactly why a generated number is accepted by a client-side validator and refused by an issuer — the shape is right and the account behind it does not exist.

A custom BIN or prefix replaces the brand’s own while keeping the brand’s length and check digit, so one issuer range can be exercised on its own. It must be digits only and leave at least two positions free, one random digit and the checksum, or every number would come out identical; the field says so instead of generating. Expiry dates fall one to thirty-six months ahead of today, the CVV is three random digits (four for American Express) and the holder is a name from a short list for the chosen country, which changes nothing about the number itself.

Examples

Generate a Visa test number

Sixteen digits grouped in fours, opening with a 4 and closing with the check digit that brings the Luhn sum to a multiple of ten. This is one real run of the generator; every run gives a different number.

Settings
Card brand: Visa
Quantity: 1
Card number
4204 5205 9513 9281

Pin the number to one BIN

The six typed digits replace the Visa prefix; the next nine are random and the last is the checksum, so only the prefix survives from one run to the next. Use it to hit a routing or surcharge rule that keys on the first six or eight digits.

Settings
Card brand: Visa
Custom BIN / prefix: 411111
Card number
4111 1166 5483 6404

Copy an American Express card as one line

Copy writes the unformatted number, the expiry and the CVV separated by spaces, which pastes into a fixture or a test script without editing. An Amex number is fifteen digits, shown 4-6-5 in the table, with a four-digit CVV; the expiry is a random month one to thirty-six ahead of the day it was made.

Settings
Card brand: Amex
Copy card
Copied text
373638377254970 09/29 8589

Ask for a prefix that leaves no room for the checksum

Fifteen digits on a sixteen-digit brand would leave nothing random and nothing to check, so the field reports it and the cards on screen stay as they were. Letters or dashes are refused as not digits only, and while an error stands Generate falls back to the brand’s own prefix.

Settings
Card brand: Visa
Custom BIN / prefix: 444444444444444
Field error
Too long: a Visa number has 16 digits, so a prefix can have at most 14

Supported formats

  • Six brands at their real lengthsVisa, Mastercard, Discover and JCB at 16 digits, American Express at 15 and Diners Club at 14, each opening with a prefix from the brand’s issuer ranges and displayed as it is embossed: 4-4-4-4, 4-6-5 or 4-6-4.
  • Expiry and CVVExpiry as MM/YY, one to thirty-six months after today. A three-digit CVV, or four digits for American Express.
  • Custom BIN or prefixDigits only, up to two fewer than the brand’s length (14 for a 16-digit brand), replacing the brand prefix for every card in the batch. Spaces typed into the field are dropped.
  • Holder names for twenty countriesA first name and a surname from a short list per country, written in upper case; Chinese names are written family name first with no space, Russian ones in Cyrillic. The country changes the names only.
  • Plain-text copyOne card per line as number, expiry and CVV separated by spaces, for one card or all of them — up to 100 at a time.

Use cases

  • Payment form QAType generated numbers into a checkout to check that brand detection shows the right logo, that the Luhn check passes, that formatting groups the digits as you type and that masking leaves only the last four.
  • Fixtures and seed dataCopy All gives up to a hundred cards with expiry and CVV columns in one paste, so a test database or a factory file is not full of one hard-coded 4111 1111 1111 1111.
  • Exercising one issuer rangeA custom BIN produces a batch that all start with the same six or eight digits, for a routing rule, a surcharge table or a BIN lookup that must behave differently for one issuer.
  • Mockups, demos and screenshotsA wallet or billing screen populated with plausible cards, holder names from the right country and valid-looking dates, without photographing anyone’s real card.

Limitations

  • Test numbers only — nothing can be chargedNo bank issued these numbers and no account sits behind them, so an authorisation fails at the first step. They exist to exercise your own code; presenting one as a means of payment is attempted fraud whatever the outcome.
  • Gateway sandboxes want their own cardsStripe, Adyen, Braintree and PayPal recognise only the test numbers they publish, each wired to an outcome such as a decline. Generated numbers are for validation, display and fixtures, not sandbox transactions.
  • Only the common lengths and brandsVisa is generated at 16 digits, never 13 or 19, and Maestro, UnionPay, RuPay, Elo and private-label cards are not offered. The expiry and CVV are random, not derived from the number, so no issuer-specific rule is modelled.
  • It does not check a number you already haveThere is no input for pasting a card number to see whether it passes Luhn or which brand it is; the page only generates. Run that check in your own validator or a unit test.
  • The country changes the name, not the BINReal issuer ranges are tied to a bank and a country; here the country select only picks the holder’s name. A test that needs a card issued in a particular country needs a custom BIN from that issuer.

Frequently asked questions

Are these real credit card numbers?

No. They are randomly generated numbers that happen to satisfy the Luhn check and carry a recognisable brand prefix, which is all that makes a number well-formed. No account, bank, holder or balance exists behind any of them, and no funds can be moved with one.

What is the Luhn algorithm?

A checksum invented in 1954 that every payment card number satisfies. Doubling every second digit from the right, adding the digits of any result over nine, and summing the lot gives a multiple of ten. It catches every single-digit typo and most transposed pairs — swapping an adjacent 0 and 9 is the one it misses — which is why forms can reject a mistyped card before contacting the network at all.

What are these numbers actually for?

Exercising code that handles card numbers: checking that your validation accepts a well-formed number, that brand detection picks the right logo, that formatting and masking behave, and that your test fixtures are not full of one hard-coded number. They test the shape of a card number, not a payment.

Can I buy anything with one?

No. Authorisation is an online check against a real issuer and a real account, and these numbers match neither, so any attempt fails at the first step. Attempting to pay with a generated number is attempted fraud regardless of the outcome — this is a developer tool, not a way around a payment.

Which card brands are supported?

Visa, Mastercard, American Express, Discover, JCB and Diners Club, each generated with a prefix from that brand’s real issuer identification ranges and at the brand’s digit length — 16 digits for Visa, Mastercard, Discover and JCB, 15 for American Express and 14 for Diners Club — so brand detection code sees exactly what it would see in production. Visa also issues 13- and 19-digit cards, which this tool does not generate. To test one specific issuer range, type a custom BIN or prefix and it replaces the brand’s own.

Should I use these to test a payment gateway sandbox?

No — use the gateway’s own test numbers. Stripe, Adyen, PayPal and the rest publish specific cards wired to specific outcomes, including declines and 3-D Secure challenges, and their sandboxes only recognise those. Generated numbers are for your own validation and display code.

Are the generated numbers logged anywhere?

No. The whole tool is JavaScript running in your own browser, so nothing you type or paste is sent over the network, written to a log or attached to an analytics event. You can confirm it by opening the network tab and watching it stay empty while you work.