Advertisement

Prefix 51–55, 2221–2720 · 16 digits · 3-digit CVV

Mastercard Number Generator

Generate 16-digit Mastercard test numbers from both the classic 51–55 range and the newer 2-series range, with expiry date and CVC.

Advertisement
Generated cards

Test data only — these numbers are not issued by any bank and every real payment with them will be declined.

Advertisement

Generated locally with your browser’s crypto API — nothing is sent to a server.

Mastercard format

Starts with
51–55, 2221–2720
Length
16
Security code
3
Stripe
5555 5555 5555 4444
Advertisement

Brand ranges at a glance

The prefixes and lengths your checkout must accept. Each brand has its own generator page.

For developers & QA

Test data that stays out of PCI scope

Use generated numbers for everything before the payment request, then switch to your gateway’s official sandbox cards for approvals, declines and 3-D Secure.

  • Test form validation & input masks
  • Seed staging databases and demos
  • Reproduce declines and 3-D Secure in the sandbox
Browse gateway test cards

Official sandbox cards, per gateway

All 18 gateways →

About Mastercard card numbers

Mastercard is the second-largest card network worldwide. Like Visa, it does not issue cards directly; banks issue Mastercard credit, debit and prepaid cards and Mastercard operates the network and sets the rules, including the numbering ranges.

For decades every Mastercard number started with 51 to 55. Because that range was running out, Mastercard added the 2-series range 2221–2720 in 2017. Many older validation scripts still only accept numbers starting with 5, so a 2-series number is one of the most useful test cases you can run: if your form rejects it, real customers with new cards are being turned away.

Mastercard numbers are always 16 digits and carry a 3-digit card verification code (CVC2) on the back. The generator above mixes both ranges at random; type 2221 or 5 in the BIN field to force one of them.

Mastercard number format

Starts with (IIN)51–55 and 2221–2720
Number length16 digits
Typical layout5xxx xxxx xxxx xxxx or 2xxx xxxx xxxx xxxx
Security code3-digit CVC2 on the back
Check digitLast digit, calculated with the Luhn (mod 10) algorithm
NetworkMastercard Inc.
Advertisement

Official Mastercard sandbox test numbers

Payment gateways publish fixed test numbers that only work in their test mode. Use them when you need a predictable gateway response; use the generator above for bulk or randomized data.

GatewayTest number
Stripe5555 5555 5555 4444
Stripe (2-series)2223 0031 2200 3222
Braintree5555 5555 5555 4444

Sources: the gateways' own documentation — Stripe, PayPal, Braintree, Adyen.

How to test Mastercard payments safely

  1. Generate a batch of Mastercard numbers above and paste them into your form to confirm brand detection, length and formatting.
  2. Change one digit of a generated number — your form should now reject it, because the Luhn check fails. You can confirm why with the validator.
  3. Switch your payment provider to sandbox / test mode and use its documented test cards for authorization, decline and 3-D Secure scenarios.
  4. Never use real customer card numbers in development or staging environments.
Generated Mastercard numbers are for testing only. They are not linked to any Mastercard account, hold no balance and will be declined by any live payment system.

Frequently asked questions

What numbers do Mastercard cards start with?

Mastercard numbers start with 51–55 or with 2221–2720. The second range was introduced in 2017, so make sure your validation accepts both.

What is a Mastercard test number for Stripe?

Stripe documents 5555 5555 5555 4444 and the 2-series 2223 0031 2200 3222. Use any future expiry date and any 3-digit CVC in test mode.

Is Maestro the same as Mastercard?

Maestro is a debit brand owned by Mastercard, but it uses different prefixes (such as 5018, 5020, 6304 and 6759) and lengths from 12 to 19 digits. Select Maestro in the generator to create those numbers.

Are these real credit card numbers?

No. The numbers follow the public format rules of each card network (prefix, length and Luhn check digit), but they are not linked to any bank account, cardholder or credit line. They exist only to test software.

Can I buy something or start a free trial with a generated card?

No. A real payment needs an authorization from the issuing bank, and no bank has issued these numbers, so every charge is declined. Trying to pay with a number you do not own is fraud. Use them only in sandboxes, forms and test data.

Related tools

Advertisement