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 length | 16 digits |
| Typical layout | 5xxx xxxx xxxx xxxx or 2xxx xxxx xxxx xxxx |
| Security code | 3-digit CVC2 on the back |
| Check digit | Last digit, calculated with the Luhn (mod 10) algorithm |
| Network | Mastercard Inc. |
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.
| Gateway | Test number | |
|---|---|---|
| Stripe | 5555 5555 5555 4444 | |
| Stripe (2-series) | 2223 0031 2200 3222 | |
| Braintree | 5555 5555 5555 4444 |
Sources: the gateways' own documentation — Stripe, PayPal, Braintree, Adyen.
How to test Mastercard payments safely
- Generate a batch of Mastercard numbers above and paste them into your form to confirm brand detection, length and formatting.
- 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.
- Switch your payment provider to sandbox / test mode and use its documented test cards for authorization, decline and 3-D Secure scenarios.
- Never use real customer card numbers in development or staging environments.
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.