Skip to content
Credit cards

Credit Card Generator

Generate valid credit card numbers for testing purposes. Supports Visa, Mastercard, American Express, and Discover with Luhn algorithm validation.

Operation Mode

Quick Quantity:

Enter 2–6 custom starting digits. The rest of the number will be generated with valid Luhn checksums.

Generated Card Primary Number

4532 6101 5115 8263

Visa • EXP 04/30 • CVV 318 • Luhn Valid

Test Mode
Visa

4532 6101 5115 8263

Cardholder Name

Lucas Perez

Expires

04/30

CVV

318

Generated Cards (5)

Click any field or use batch export formats

#1 Visa4532 6101 5115 8263

Lucas Perez • EXP: 04/30 • CVV: 318Chase Sandbox Bank

#2 Discover6221 6845 2010 4655

Ava Wilson • EXP: 04/30 • CVV: 475Barclays Test Bank

#3 JCB3566 6746 2996 3010

Sophia Anderson • EXP: 02/28 • CVV: 360Apex Financial Test

#4 Diners Club3001 911894 5546

Jordan Harris • EXP: 04/29 • CVV: 561Apex Financial Test

#5 JCB3528 3048 7961 3951

Taylor Jones • EXP: 11/27 • CVV: 308Wells Fargo QA

Card Network Breakdown

  • Visa1 card20.0%
  • Discover1 card20.0%
  • JCB2 cards40.0%
  • Diners Club1 card20.0%
Report tool

How credit card number generation and the Luhn algorithm work

Payment card numbers issued worldwide adhere to strict structural standards defined by the International Organization for Standardization (ISO/IEC 7812). Whether issued by Visa, Mastercard, American Express, Discover, JCB, or Diners Club, payment card numbers are not random sequences of digits. Instead, they encode the issuing industry, the financial institution, the individual account identifier, and a mathematical checksum known as the Luhn algorithm (Modulo 10).

In software engineering, QA testing, and e-commerce development, engineers need synthetically generated test card numbers to validate checkout flows, card input formatters, and billing engines without handling live financial instruments. If you already have card numbers to inspect, verify their checksums with our credit card validator. Once you verify payment processing flows, you can evaluate interest structures with our APR calculator, examine structured repayment plans with our credit card EMI calculator, compare balance consolidation strategies using our balance transfer calculator, or analyze reward rates with our cash back calculator.

Anatomy of a payment card number (ISO/IEC 7812)

Standard payment cards contain between 13 and 19 numerical digits partitioned into three primary functional segments:

1. Major Industry Identifier (MII) and Issuer Identification Number (IIN/BIN)

The very first digit represents the Major Industry Identifier (MII), which categorizes the issuing institution:

  • 1 and 2: Airlines and financial services
  • 3: Travel and entertainment (American Express, Diners Club, JCB)
  • 4: Banking and financial networks (Visa)
  • 5: Banking and financial networks (Mastercard)
  • 6: Merchandising and banking (Discover, China UnionPay, Maestro)
  • 7: Petroleum and fuel cards
  • 8: Telecommunications and healthcare
  • 9: National assignment and open testing

The first 6 to 8 digits comprise the Bank Identification Number (BIN) or Issuer Identification Number (IIN). This prefix uniquely identifies the card network, the issuing financial institution, and the card tier (such as debit, business, credit, or platinum).

2. Individual account identifier

The middle sequence (from digit 7 up to the penultimate digit) represents the individual account number assigned by the card issuer. This portion allows issuers to allocate billions of distinct primary account numbers (PANs).

3. The checksum digit (Luhn check digit)

The final digit of the card number is the check digit. It is mathematically calculated using the Luhn algorithm to protect against accidental typing errors, transposition mistakes, and random digit corruption.

The mathematics of the Luhn algorithm (Modulo 10)

Invented by IBM scientist Hans Peter Luhn in 1954, the Luhn formula verifies numerical sequences by applying a checksum formula across the digits.

Step-by-step Luhn validation formula

Given a numerical sequence d1,d2,,dnd_1, d_2, \dots, d_n of length nn:

  1. Starting from the rightmost digit (the check digit, position 1 from right) and moving leftwards, leave the first digit unaltered.
  2. Double the value of every alternating digit (position 2, 4, 6, 8, etc. counting from the right).
  3. If the product of the doubling operation exceeds 9, subtract 9 from the product (which equals the sum of the product two individual digits, e.g., 2×7=14    1+4=5=1492 \times 7 = 14 \implies 1 + 4 = 5 = 14 - 9).
  4. Sum all altered and unaltered digits together to produce total checksum SS:
S=k=1nf(dnk+1,k),where f(d,k)={dif k is odd2d9if k is even and 2d>92dif k is even and 2d9S = \sum_{k=1}^{n} f(d_{n - k + 1}, k), \quad \text{where } f(d, k) = \begin{cases} d & \text{if } k \text{ is odd} \\ 2d - 9 & \text{if } k \text{ is even and } 2d > 9 \\ 2d & \text{if } k \text{ is even and } 2d \le 9 \end{cases}

The card number is valid under the Luhn algorithm if and only if the total sum is an exact multiple of 10:

S0(mod10)    Smod10=0S \equiv 0 \pmod{10} \iff S \bmod 10 = 0

Calculating the check digit for test data generation

When generating a synthetic test card, we choose an authorized IIN/BIN prefix and fill intermediate account digits randomly up to length n1n - 1. To determine the required check digit dnd_n, we compute partial sum SpartialS_{\text{partial}} where the digit immediately preceding the check digit is doubled:

dn=(10(Spartialmod10))mod10d_n = (10 - (S_{\text{partial}} \bmod 10)) \bmod 10

Worked example of Luhn verification

Let us examine the sample 16-digit card number 4532 7500 1234 5673:

Position (L to R)Original DigitDouble? (From Right)OperationContribution
14Yes (even pos 16)4 x 2 = 88
25No (odd pos 15)unaltered5
33Yes (even pos 14)3 x 2 = 66
42No (odd pos 13)unaltered2
57Yes (even pos 12)7 x 2 = 14 (14 - 9)5
65No (odd pos 11)unaltered5
70Yes (even pos 10)0 x 2 = 00
80No (odd pos 9)unaltered0
91Yes (even pos 8)1 x 2 = 22
102No (odd pos 7)unaltered2
113Yes (even pos 6)3 x 2 = 66
124No (odd pos 5)unaltered4
135Yes (even pos 4)5 x 2 = 10 (10 - 9)1
146No (odd pos 3)unaltered6
157Yes (even pos 2)7 x 2 = 14 (14 - 9)5
163No (check digit, pos 1)unaltered3

Summing all contributions: 8+5+6+2+5+5+0+0+2+2+6+4+1+6+5+3=608 + 5 + 6 + 2 + 5 + 5 + 0 + 0 + 2 + 2 + 6 + 4 + 1 + 6 + 5 + 3 = 60.

Applying Modulo 10: 60mod10=060 \bmod 10 = 0. Since the remainder is 0, the number is mathematically valid.

Major card networks and technical specifications

Card NetworkIIN / BIN PrefixesTotal LengthCVV DigitsGrouping Format
Visa416 (or 13)3 digits4-4-4-4
Mastercard51-55, 2221-2720163 digits4-4-4-4
American Express34, 37154 digits4-6-5
Discover6011, 622126-622925, 644-649, 65163 digits4-4-4-4
JCB3528-3589163 digits4-4-4-4
Diners Club300-305, 36, 38143 digits4-6-4
UnionPay6216 to 193 digits4-4-4-4

Payment gateway sandbox testing best practices

When integrating payment gateways such as Stripe, PayPal, Braintree, Square, or Adyen, developers use synthetic test cards in development sandboxes. Keep these technical guidelines in mind:

  • Client-side form validation: Verify that checkout forms correctly apply formatting spaces, validate input lengths, and execute client-side Luhn checks before sending tokenization requests.
  • Sandbox gateway responses: Payment gateways map specific test card numbers or CVV values to test scenarios (such as approved charges, 3D Secure challenges, insufficient funds, or expired cards).
  • Synthetic cards have no monetary balance: Generated test cards are mathematical constructs. They do not connect to live banking networks or store actual funds. If you need to estimate transaction processing costs for digital wallets, see our Cash App fee calculator.

Frequently asked questions

Can these generated credit card numbers be used to make real purchases?
No. These generated credit card numbers are synthetic test data created strictly for software development, QA testing, and UI validation. They do not correspond to real open bank accounts, have no credit limit, and will fail immediate authorization on live payment processors.
What errors does the Luhn algorithm detect?
The Luhn algorithm detects all single-digit entry errors (e.g., typing 4 instead of 7) and almost all adjacent digit transposition errors (e.g., typing 45 instead of 54, with the exception of 09 vs 90). It does not detect twin error cancellations where multiple errors sum to a multiple of 10.
Why does American Express have 15 digits while Visa has 16 digits?
Card length is governed by ISO/IEC 7812 and network-specific routing rules. American Express uses a 15-digit PAN structured in a 4-6-5 format with a 4-digit CID/CVV printed on the front of the card. Visa, Mastercard, and Discover standardize on 16 digits partitioned in 4-4-4-4 blocks with a 3-digit CVV on the signature panel.
How is a card CVV or CVC code calculated by banks?
The Card Verification Value (CVV/CVC) is calculated by the issuing bank by encrypting the primary account number (PAN), expiration date, and service code using a secret cryptographic Data Encryption Standard (3DES) key. Because the CVV requires the issuer private key, synthetic CVVs used in testing are mock placeholders.
What is the difference between a BIN and an IIN?
Bank Identification Number (BIN) is the traditional industry term for the first digits of a payment card. Under ISO/IEC 7812 updates, the standard expanded BINs to 8 digits and formally adopted the term Issuer Identification Number (IIN) to accommodate non-bank fintech issuers.
How can I test credit card interest and installment plans in development?
To model revolving interest calculations or monthly installment conversions for e-commerce checkout systems, use our credit card EMI calculator or explore APR compounding mechanics with our APR calculator.

Resources and references

The formulas and methods in this calculator were checked against these independent sources.