About Mastercard card numbers
Mastercard is the second-largest card network outside China, after Visa. 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 card number format and example
| 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. |
| Example (test number) | 5555 5555 5555 4444 |
Official Mastercard sandbox test numbers
3 gateways publish fixed Mastercard numbers that work only in test mode, for a predictable gateway response; the generator above is 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, Braintree.
Mastercard number examples (5-series and 2-series)
A complete Mastercard test plan needs one number from each range, because they fail in different places: old validation code often accepts only numbers starting with 5, and some input masks mis-group numbers starting with 2.
| Range | Example (Stripe test number) | What it tests |
|---|---|---|
| 51–55 | 5555 5555 5555 4444 | Classic prefix, accepted by almost every form |
| 2221–2720 | 2223 0031 2200 3222 | 2-series detection, logo and grouping |
Both numbers only work in Stripe test mode. For your own Mastercard number, look at the card itself or the card details in your bank’s app — a generator cannot tell you a real number.
Need a billing address and ZIP code as well? Tick Add billing address & ZIP (US) above; how address (AVS) testing works is explained on the Visa generator page.
What to test with Mastercard numbers
Test one number from the 51–55 range and one from the 2-series (type 2221 in the BIN field): both must be detected as Mastercard. Rejecting the 2-series is the most common Mastercard validation bug.
Then change one digit of a generated number: the form should now reject it because the Luhn check fails (the validator shows why). Approvals, declines and 3-D Secure need your gateway's sandbox cards, listed above.
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.
Where do I find my own Mastercard number?
On the front (or back) of your physical card, and in your bank’s app under card details. Generated numbers are not anyone’s card — they only exist to test forms.
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.