Mastercard Test Card Numbers: Generate & Validate Cards | Namso Gen
Mastercard Test Card Numbers: Generate & Validate Cards

Mastercard Test Card Numbers: Generate & Validate Cards

Mastercard test card numbers for Stripe, PayPal, Braintree, Adyen, and more. Learn the 5xx and 2-series BIN ranges and generate custom Luhn-valid cards.

Written by David S · Published on May 26, 2026
#mastercard test card #mastercard card generator #mastercard test numbers #mastercard credit card generator #mastercard test card numbers #mastercard 2-series bin #5xx test cards

If you build checkout flows, integrate a payment gateway, or run QA on an e-commerce platform, you need Mastercard test card numbers. Not real ones — valid-format numbers that pass client-side validation and Luhn checks without touching anyone's bank account.

Mastercard is the second most widely accepted card network on the planet, right behind Visa. Any payment integration worth shipping has to handle Mastercard correctly, including the newer 2-series BIN range that confuses a surprising amount of validation code written before 2017.

This guide covers everything: Mastercard number structure, the classic 5xx and modern 2-series ranges, official sandbox test cards from every major gateway, how to generate your own with Namso Gen, BIN ranges by issuer and country, and the exact validation rules your code should enforce. Bookmark it — you'll come back.


How Mastercard Card Numbers Work

Every Mastercard number follows the ISO/IEC 7812 standard, the same structure that governs Visa, Amex, and the rest. Knowing the structure makes you a better tester because you'll understand why a number passes or fails validation.

The Mastercard Number Structure

Position Digits Purpose
1 5 or 2 Major Industry Identifier (MII) — banking/financial
1–6 (or 1–8) 5XXXXX / 2XXXXX Bank Identification Number (BIN/IIN) — identifies the issuer
7–15 Variable Account number — unique to the cardholder
16 (last) Check digit Calculated using the Luhn algorithm

Key facts about Mastercard numbers:

  • 16 digits. Standard Mastercard credit and debit cards are always 16 digits. There is no widely issued 13- or 15-digit Mastercard.
  • Two valid prefix families. Historically Mastercard used 5155. Since 2017 it also issues cards in the 2-series, specifically 22212720. Both are valid Mastercard.
  • The check digit is not random. The last digit is computed with the Luhn algorithm. You can't invent 16 digits starting with 5 and expect them to validate.
  • CVC is 3 digits. Mastercard calls it CVC2. It's printed on the signature panel and is never 4 digits (that's Amex).

The 2-Series: The Range Everyone Forgets

In 2017 Mastercard expanded its BIN space by activating the 22212720 range. This was a response to running low on numbers in the 5155 block. The catch: a lot of legacy validation logic only checked for 5155 and silently rejected perfectly valid 2-series Mastercards.

If you maintain a regex or card-detection routine, this is the single most important thing to test. A correct Mastercard detector must accept both families:

Family Range Example BIN
Classic 5-series 5155 5105 10, 5555 55
Modern 2-series 22212720 2221 00, 2720 99

Generate a batch from each range with Namso Gen and run them through your validator. If the 2-series cards bounce, you've found a real bug before it reached production.

BIN Ranges: What the First 6–8 Digits Tell You

The BIN (Bank Identification Number) encodes the issuing bank, card type, and country. Since April 2022 the industry has been migrating from 6-digit BINs to 8-digit IINs (Issuer Identification Numbers), though 6-digit BINs remain widely used.

For a deeper dive into BIN structure across all networks, read our complete BIN guide. To look up which bank a specific BIN belongs to, use the BIN Checker.


Official Mastercard Test Card Numbers by Gateway

Every major payment gateway ships sandbox test cards. Here are the Mastercard-specific ones you'll reach for most often.

Stripe

Card Number Scenario CVC Expiration
5555 5555 5555 4444 Successful payment Any 3 digits Any future date
2223 0031 2200 3222 Successful (2-series) Any 3 digits Any future date
5200 8282 8282 8210 Debit card — success Any 3 digits Any future date
5105 1051 0510 5100 Prepaid card — success Any 3 digits Any future date
4000 0000 0000 0002 Generic decline (any brand) Any 3 digits Any future date
5455 3307 6000 0018 Requires 3D Secure Any 3 digits Any future date

Stripe's 5555 5555 5555 4444 is the Mastercard equivalent of the famous 4242 Visa card — the one developers paste in by muscle memory. The 2223... card is essential for confirming your integration handles the 2-series.

PayPal (Braintree Sandbox)

Card Number Scenario
5555 5555 5555 4444 Successful transaction
5105 1051 0510 5100 Successful (prepaid)
2223 0000 4841 0010 Successful (2-series)
5454 5454 5454 5454 Successful (alternate)

Adyen

Card Number Scenario
5555 4444 3333 1111 Successful payment
5500 0000 0000 0004 Successful (alternate)
2222 4000 7000 0005 2-series success
5454 5454 5454 5454 3D Secure enrolled

Checkout.com

Card Number Scenario
5436 0310 3060 6378 Successful payment
5200 0000 0000 0007 Declined
5200 0000 0000 0023 Soft decline
5200 0000 0000 0114 3D Secure required

Square

Card Number Scenario
5105 1051 0510 5100 Mastercard — successful charge

MercadoPago (Latin America)

Card Number Scenario
5031 7557 3453 0604 Mastercard — approved
5031 4332 1540 6351 Mastercard — rejected

Pro tip: Gateway test cards only work in sandbox/test mode. They'll always fail in production. For broader testing — form validation, load testing, BIN-specific scenarios, 2-series coverage — you need to generate your own. That's where Namso Gen comes in.


Generate Custom Mastercard Test Cards with Namso Gen

Gateway test cards cover the happy path. Real-world QA demands more. What if you need:

  • 100 Mastercard numbers for a load test?
  • Cards from a specific BIN (a Capital One Mastercard, or a UK-issued Mastercard debit)?
  • Coverage for both the 5-series and the 2-series?
  • Test data for multiple subtypes (Standard, Gold, World, World Elite, Maestro)?

Namso Gen generates Luhn-valid Mastercard numbers in bulk. Here's the workflow.

Step 1: Enter a Mastercard BIN

Open namso.tools, select the Mastercard preset (or visit the dedicated Mastercard generator), and enter a BIN. For example:

BIN Family Notes
510510 5-series Generic Mastercard test BIN
555555 5-series Classic test range
222100 2-series Lowest 2-series BIN
272099 2-series Highest 2-series BIN
520082 5-series Mastercard debit
222300 2-series Modern credit

Not sure which BIN to use? Look one up with the BIN Checker or check our BIN guide for common ranges.

Step 2: Configure Generation

  • Quantity: 1 to thousands for bulk and load testing.
  • Format: 16 digits is standard for Mastercard.
  • Expiry date: Set a future date or let Namso Gen randomize it.
  • CVV: Generate random 3-digit CVCs (Mastercard uses CVC2, always 3 digits).

Step 3: Generate and Copy

Click Generate. You'll get a batch of Luhn-valid Mastercard numbers ready to paste straight into your test environment.

Example output:

5555 5512 8847 3309  |  08/28  |  410
5555 5538 9920 1145  |  03/27  |  762
2223 0049 6612 8836  |  11/29  |  205
2720 9971 4408 5521  |  06/28  |  648
5105 1078 3391 2203  |  01/30  |  517

Every number passes Luhn validation and looks like a real Mastercard to any form validator — but none of them is connected to a real account.


Mastercard Card Validation Rules

If you're building or testing payment form validation, here are the rules your code should enforce for Mastercard:

Rule Requirement
Prefix Must start with 5155 or 22212720
Length Exactly 16 digits
Luhn check Last digit must satisfy the Luhn algorithm
CVC (CVC2) 3 digits, printed on the signature panel
Expiry MM/YY format, must be a future date

Quick JavaScript Validation

function isValidMastercard(number) {
  const cleaned = number.replace(/\s|-/g, '');

  // Must be 16 digits, prefix 51-55 or 2221-2720
  if (!/^\d{16}$/.test(cleaned)) return false;
  const first2 = parseInt(cleaned.slice(0, 2), 10);
  const first4 = parseInt(cleaned.slice(0, 4), 10);
  const is5Series = first2 >= 51 && first2 <= 55;
  const is2Series = first4 >= 2221 && first4 <= 2720;
  if (!is5Series && !is2Series) return false;

  // Luhn check
  let sum = 0;
  for (let i = cleaned.length - 1; i >= 0; i--) {
    let digit = parseInt(cleaned[i], 10);
    if ((cleaned.length - i) % 2 === 0) {
      digit *= 2;
      if (digit > 9) digit -= 9;
    }
    sum += digit;
  }
  return sum % 10 === 0;
}

// Test it
console.log(isValidMastercard('5555 5555 5555 4444')); // true (5-series)
console.log(isValidMastercard('2223 0031 2200 3222')); // true (2-series)
console.log(isValidMastercard('4111 1111 1111 1111')); // false (that's Visa)
console.log(isValidMastercard('5555 5555 5555 4445')); // false (bad Luhn)

Quick Python Validation

import re

def is_valid_mastercard(number: str) -> bool:
    cleaned = re.sub(r'[\s-]', '', number)

    # Must be 16 digits, prefix 51-55 or 2221-2720
    if not re.match(r'^\d{16}$', cleaned):
        return False
    first2 = int(cleaned[:2])
    first4 = int(cleaned[:4])
    if not (51 <= first2 <= 55 or 2221 <= first4 <= 2720):
        return False

    # Luhn check
    digits = [int(d) for d in cleaned]
    for i in range(len(digits) - 2, -1, -2):
        digits[i] *= 2
        if digits[i] > 9:
            digits[i] -= 9
    return sum(digits) % 10 == 0

# Test it
print(is_valid_mastercard('5555 5555 5555 4444'))  # True
print(is_valid_mastercard('2223 0031 2200 3222'))  # True
print(is_valid_mastercard('4111 1111 1111 1111'))  # False

Notice that the only real difference between this and a Visa validator is the prefix rule. The Luhn step is identical for every card network — which is exactly why Namso Gen can generate valid numbers for any brand from a single algorithm.


Common Mastercard BINs by Issuer and Country

For testing region-specific or issuer-specific scenarios, here are widely known Mastercard BIN ranges. Verify any of them with the BIN Checker.

United States

BIN Range Issuer Card Type
5424 18 Capital One Mastercard
5466 16 Citibank World Mastercard
5178 05 Bank of America Mastercard
5573 50 Wells Fargo Mastercard
2221 00 US issuer (2-series) Mastercard

United Kingdom

BIN Range Issuer Card Type
5301 25 NatWest Mastercard Debit
5413 30 Halifax Mastercard
5573 09 Monzo Mastercard Debit
2347 16 Starling Bank Mastercard Debit (2-series)

Europe

BIN Range Issuer Country Card Type
5355 70 Deutsche Bank Germany Mastercard
5239 36 BNP Paribas France Mastercard
2200 00 Various EU Mastercard (2-series)
5168 00 UniCredit Italy Mastercard

Latin America

BIN Range Issuer Country Card Type
5031 75 Mercado Pago Argentina Mastercard
5453 23 Nubank Brazil Mastercard
5204 16 Bancolombia Colombia Mastercard
5579 08 BBVA Mexico Mastercard

Asia-Pacific

BIN Range Issuer Country Card Type
5520 00 DBS Bank Singapore Mastercard
5241 86 HDFC Bank India Mastercard
5163 20 Commonwealth Bank Australia Mastercard
5294 00 Bangkok Bank Thailand Mastercard

Remember: These BIN ranges are for testing and educational purposes only. Use the BIN Checker to verify any BIN's issuer, country, and card type before relying on it.


Mastercard Subtypes: Standard, Gold, World, World Elite, Maestro

Not all Mastercards behave the same. Subtypes carry different BIN ranges, benefits, and interchange tiers — and occasionally different acceptance rules. When testing, it can matter.

Subtype Description CVC Digits
Standard Everyday consumer credit/debit 3
Gold Mid-tier with travel perks 3
World Premium tier, higher limits 3
World Elite Top tier, concierge and lounge benefits 3
Maestro Debit-only, common in Europe (variable length) 3
Mastercard Prepaid Reloadable, no linked bank account 3

Testing tip: Maestro is the one to watch. Some Maestro cards historically used 18- or 19-digit numbers and required online authorization. If your checkout accepts Maestro, generate test data that exercises those edge cases and confirm your validator doesn't assume a fixed 16-digit length for every Mastercard product.


Gateway Test Cards vs Generated Cards: When to Use Each

Scenario Use Gateway Test Cards Use Namso Gen
Basic payment flow
Specific decline/error codes
3D Secure testing
Form field validation
2-series BIN coverage
Bulk/load testing
BIN-specific testing
Region/country-specific cards
Subtype testing (World, Maestro)
Unit tests (no gateway connection)
Automated QA suites ✅ + ✅ Combine both

The sweet spot: use gateway test cards for end-to-end payment flow testing, and use Namso Gen for everything else — form validation, bulk generation, 2-series coverage, and any test that doesn't need a live gateway connection.

For a side-by-side comparison of both approaches, see our Credit Card Generator for Testing guide, and for the Visa equivalent of this article, read Visa Test Card Numbers.


Frequently Asked Questions

Are Mastercard test card numbers real credit card numbers?

No. Test card numbers — whether from gateways or a generator like Namso Gen — are not linked to any real bank account. They follow the correct format and pass Luhn validation, but they cannot be used for actual purchases and carry no monetary value.

Why do Mastercard numbers start with 5 or 2?

The first digit is the Major Industry Identifier (MII); 5 and 2 are both assigned to banking and financial institutions. Mastercard originally used the 5155 block, then activated the 22212720 (2-series) range in 2017 when the older block began running out of available numbers. Both are valid Mastercard prefixes.

What is the Mastercard 2-series and why does it matter for testing?

The 2-series is the 22212720 BIN range Mastercard introduced in 2017. It matters because a lot of older validation code only recognized 5155 and silently rejected valid 2-series cards. Always test both ranges — generate a batch of each with Namso Gen and confirm your validator accepts them.

Can I use Stripe's Mastercard test card in PayPal's sandbox?

No. Each gateway has its own sandbox test cards that only work in that gateway's environment. Stripe's 5555 5555 5555 4444 won't authorize in PayPal's sandbox. Use the gateway-specific cards listed above, or generate your own with Namso Gen for non-gateway testing.

How many digits does a Mastercard number have?

Standard Mastercard credit and debit cards are 16 digits. The main exception is Maestro, a Mastercard debit brand that has historically used variable lengths (up to 19 digits). Your validation should default to 16 digits but account for Maestro if you accept it.

Is it legal to use generated Mastercard test numbers?

Yes. Generating Luhn-valid test numbers for development and QA is completely legal. These numbers don't correspond to real accounts and can't be used for transactions. Testing with synthetic card data is standard industry practice. For more detail, read our safe credit card generator guide.

How do I generate a Mastercard test card for a specific country or bank?

Find the issuer's BIN (the first 6–8 digits) using the BIN Checker or our BIN guide, then enter it into Namso Gen. The generator fills in the rest with Luhn-valid digits, giving you region- and issuer-specific test cards.

What's the difference between Mastercard CVC and Visa CVV for testing?

Functionally nothing for test data — both are the 3-digit security code on the back of the card (Mastercard calls it CVC2, Visa calls it CVV2). Both are 3 digits, unlike Amex's 4-digit CID. Namso Gen generates valid-format 3-digit codes for Mastercard automatically.