Skip to content

Test card number generator and Luhn checker

Get a working test card number for any brand and outcome, copied straight from a processor's published test cards, and check any card number with the Luhn algorithm. These numbers move no money: they work only in test mode. On Flint, every one of Stripe's test cards works in a free sandbox with any future expiry and any CVC.
Verified against official documentationReviewed Send a correction (opens in a new tab)

Generate a test card number

Expiry
Any future date
CVC
Any 3 digits
ZIP or postal code
Any ZIP code, such as 44444

Visa. Payment succeeds and the order becomes paid. Use it for card setup and renewals that succeed.

From Flint: Test cards. One of 62 documented cards for this choice. See it on every processor.

Check a card number

Spaces and dashes are fine. The check runs in your browser: nothing you type leaves this page or lands in the URL.

Test numbers only

Every number the generator gives you is one a processor publishes for testing, with a link to the processor's docs. It doesn't invent numbers. A random number that passes the Luhn check in a real brand's range can belong to a real account, and processors say to keep real cards out of testing:

  • Stripe: The Stripe Services Agreement prohibits testing in live mode with real card details.
  • Square: The sandbox doesn't accept real cards. Enter test numbers in the Web Payments SDK or In-App Payments SDK, which tokenize them, or pass a test source_id such as cnon:card-nonce-ok to CreatePayment.
  • Checkout.com: Never test with real card numbers. Sandbox requests go to https://{prefix}.api.sandbox.checkout.com.

A test number is also useless outside test mode: a live payment needs a real account that the issuer approves.

Test card numbers by brand

Each of these succeeds on Flint and Stripe with any future expiry and any CVC (four digits for American Express). The test card lookup lists declines, 3D Secure, and dispute cards on every processor.

BrandTest card numbers
American Express3782 822463 10005
3714 496353 98431
JCB3566 0020 2036 0505
3530 1113 3330 0000 Japan
Diners Club3056 9300 0902 0004
3622 720627 1667 14-digit card
Visa4242 4242 4242 4242
4000 0566 5566 5556 Debit

4000 0003 2000 0021 Argentina

4000 0007 6000 0002 Brazil
Mastercard5555 5555 5555 4444
2223 0031 2200 3222 2-series

5200 8282 8282 8210 Debit

5105 1051 0510 5100 Prepaid
Discover6011 1111 1111 1117
6011 0009 9013 9424

6011 9811 1111 1113 Debit
UnionPay6200 0000 0000 0005
6200 0000 0000 0047 Debit

6205 5000 0000 0000 004 19-digit card

Other processors publish their own sets, and each sandbox accepts only its own:

How the Luhn algorithm works

The last digit of every card number is a check digit, chosen so the whole number passes the Luhn algorithm, also called the mod 10 check. Card forms usually run it before sending anything, which catches a mistyped digit and most swapped pairs of neighbors.

  1. Starting from the rightmost digit, the check digit, move left.
  2. Double every second digit: the one before the check digit, then every other one.
  3. When a doubled digit is more than 9, subtract 9 (the same as adding its two digits).
  4. Add up every digit, doubled or not.
  5. The number is valid when the total is a multiple of 10.

For 4242 4242 4242 4242, every 4 sits in a doubled position and becomes 8, and every 2 stays 2:

Digit4242424242424242
Adds8282828282828282

The total is 80, a multiple of 10, so the number is valid. Change the last digit to 1 and the total is 79: the check fails, which is why 4242 4242 4242 4241 is Stripe's card for an invalid number.

The same check in TypeScript and Python:

TypeScript
// True when a card number passes the Luhn (mod 10) check.
export function passesLuhn(input: string): boolean {
  const digits = input.replace(/[\s-]/g, "");
  if (!/^\d{12,19}$/.test(digits)) return false;
  let sum = 0;
  for (let i = 0; i < digits.length; i++) {
    let digit = Number(digits[digits.length - 1 - i]);
    if (i % 2 === 1) {
      digit *= 2;
      if (digit > 9) digit -= 9;
    }
    sum += digit;
  }
  return sum % 10 === 0;
}

passesLuhn("4242 4242 4242 4242"); // true
passesLuhn("4242 4242 4242 4241"); // false
Python
def passes_luhn(number: str) -> bool:
    digits = number.replace(" ", "").replace("-", "")
    if not digits.isdigit() or not 12 <= len(digits) <= 19:
        return False
    total = 0
    for i, char in enumerate(reversed(digits)):
        digit = int(char)
        if i % 2 == 1:
            digit = digit * 2 - 9 if digit > 4 else digit * 2
        total += digit
    return total % 10 == 0

Passing the check says only that the number is well formed. One in ten random numbers passes. Whether the account exists, and whether the payment is approved, is the issuer's answer at authorization.

BIN, length, and check digit

A card number has three parts. The first six or eight digits are the issuer identification number, usually called the BIN, which names the brand and the issuing bank. The digits after it identify the account. The last is the Luhn check digit. Card numbers run up to 19 digits, and each brand uses its own ranges and lengths:

BrandMain rangesLengthTest card
American Express34 or 37153782 822463 10005
JCB3528 to 358916 to 193566 0020 2036 0505
Diners Club30, 36, 38, or 3914 to 193056 9300 0902 0004
Visa413, 16, 194242 4242 4242 4242
Mastercard51 to 55, or 2221 to 2720165555 5555 5555 4444
Maestro5018, 5020, 5038, 5893, 6304, 6759, or 6761 to 676312 to 196771 7980 2100 0008
Discover6011, 644 to 649, 65, or 622126 to 62292516 to 196011 1111 1111 1117
UnionPay6216 to 196200 0000 0000 0005

Read the brand from the ranges, never from the first digit alone: 6011 is Discover, 6304 is Maestro, and 62 is UnionPay except for a block Discover shares. American Express numbers are 15 digits with a 4-digit security code; most others are 16 digits with 3. Some processors publish test cards outside these main ranges, such as PayPal's JCB cards starting 3636, so the checker names the documented brand for any test card it recognizes.

Test cards on Flint

Flint is a payments API with orders, tax, and subscriptions built in, and its sandbox is free, with no credit card to sign up. One rule covers every card: any future expiry, any 3-digit CVC, any ZIP code. Flint processes cards on Stripe, so every Stripe test card works too, without a Stripe account. The ones most tests need:

CardScenarioWhat happens
4242 4242 4242 4242SuccessPayment succeeds immediately; the order becomes paid.
4000 0025 0000 3155Requires authenticationA 3D Secure challenge opens; complete it and the payment succeeds.
4000 0000 0000 9995Decline: insufficient fundsCheckout shows a payment-failed message; the order stays open.
4000 0000 0000 0002Decline: genericSame, simulating a generic issuer decline.
4000 0000 0000 0259Dispute: fraudulentPayment succeeds, then is disputed as fraudulent and waits in needs_response.

Testing lists the rest, including test tokens such as pm_card_visa for test suites that never touch a card form.

Questions, answered

What is the Luhn algorithm?

The Luhn algorithm, or mod 10 check, is the checksum every payment card number carries in its last digit. Starting from the right, double every second digit, subtract 9 from any result above 9, and add everything up. The number is valid when the total is a multiple of 10. It catches typos such as one wrong digit or most swapped neighbors; it doesn't prove a card exists.

Can a card number that passes the Luhn check still be fake?

Yes. One in ten random numbers passes, so the check only rules out mistyped numbers. Whether an account exists, has money, and belongs to the person paying is decided by the issuer when the payment is authorized.

What is a test Visa card number?

4242 4242 4242 4242 is the most widely used: it succeeds on Flint and Stripe with any future expiry and any CVC. Other processors publish their own, such as 4111 1111 1111 1111 on Braintree, and a test card only works in the sandbox of a processor that documents it.

Can I buy something with a generated card number?

No. Test card numbers work only in a processor's test mode or sandbox, where no money moves. A live payment needs a real account the issuer approves, so a test number is declined in live mode.

Why doesn't this generator make random valid card numbers?

A random number that passes the Luhn check in a real brand's range can belong to someone's real account, and processors tell you to keep real cards out of testing. So the generator draws only from the numbers processors publish for testing, which their sandboxes are built to recognize.

What are the first six digits of a card number?

The issuer identification number, also called the BIN: the first six or eight digits identify the card brand and the issuing bank. The digits after it identify the account, and the last digit is the Luhn check digit.

Sources

Every card number and outcome comes from the processor's own testing docs, linked from the generator's result and from the test card lookup. The brand ranges and lengths come from Wikipedia's Payment card number article, which follows ISO/IEC 7812, read on November 21, 2026.