networks · 2025-01-27 · 8 min read

How prefixes map to Visa, Mastercard, Amex, Discover, JCB and the rest

A complete cheat-sheet of the leading digits and lengths each network uses, plus the three traps that break most home-grown validators.

Each network claims its own slice of the number space.
Each network claims its own slice of the number space. — © Karyme França · Pexels

Card networks carve up the leading digits of the PAN between them. Knowing the map lets a form show the right logo, pick the right security-code length and format the number correctly. The live ranges table on this site highlights whichever row matches what you type.

The reference table

  • Visa — starts with 4 · 13, 16 or 19 digits · CVV2 (3 digits).
  • Mastercard — 51–55 and 2221–2720 · 16 digits · CVC2 (3).
  • American Express — 34 or 37 · 15 digits · CID (4, printed on the front).
  • Discover — 6011, 644–649, 65 and 622126–622925 · 16 or 19 digits · CID (3).
  • JCB — 3528–3589 · 16 to 19 digits · CAV2 (3).
  • Diners Club — 300–305, 3095, 36, 38–39 · 14, 16 or 19 digits · CVV (3).
  • UnionPay — 62 and 81 · 16 to 19 digits · CVN2 (3).
  • Maestro — 5018, 5020, 5038, 56–59, 6304, 6759, 6761–6763 · 12 to 19 digits · CVV (3), sometimes absent.

Trap 1: the Mastercard 2-series

Mastercard added 2221–2720 in 2016 to relieve pressure on 51–55. Old regexes that only check ^5[1-5] silently reject millions of valid cards. Mastercard's own 2-series FAQ describes the rollout; test it with Stripe's 2223 0031 2200 3222 in the test numbers.

Trap 2: shared ranges

622126–622925 belongs to both Discover and UnionPay through a network agreement, and Maestro overlaps several of the above. Always prefer the most specific match (longest prefix) rather than the first regex that happens to pass.

Trap 3: assuming 16 digits

Amex is 15, Diners is often 14, Maestro can be 12. Validators that hard-code 16 fail real customers; see why card numbers are 12 to 19 digits long.

Prefix detection is a usability feature, not a security control. It tells you which logo to show; it does not tell you whether the card is real — only an authorization does.
Visa, Mastercard, Amex: different prefixes, lengths and codes.
Visa, Mastercard, Amex: different prefixes, lengths and codes.

Keywords: card prefixes, Visa prefix, Mastercard 2-series, Amex 34 37, Discover 6011, JCB 35, card brand detection, IIN ranges

Frequently asked questions

What numbers do Visa cards start with?

All Visa cards start with the digit 4 and have 13, 16 or 19 digits.

Why does my validator reject a Mastercard starting with 2?

Because it predates the 2016 2-series expansion. Mastercard now uses 2221–2720 in addition to 51–55.

On this site

External references

Related articles

كيف تُطابق البادئات فيزا وماستركارد وأمكس وديسكفر وJCB وغيرها — النسخة العربية

ورقة مرجعية كاملة للخانات الأولى والأطوال التي تستخدمها كل شبكة، مع الفخاخ الثلاثة التي تكسر معظم المدقّقات المنزلية.

تقتسم شبكات البطاقات الخانات الأولى من رقم البطاقة فيما بينها. معرفة الخريطة تتيح للنموذج إظهار الشعار الصحيح واختيار طول رمز الأمان المناسب وتنسيق الرقم بشكل سليم. جدول النطاقات الحي في هذا الموقع يظلّل الصف المطابق لما تكتبه.

الجدول المرجعي

  • فيزا — تبدأ بـ4 · 13 أو 16 أو 19 خانة · CVV2 (3 خانات).
  • ماستركارد — 51–55 و2221–2720 · 16 خانة · CVC2 (3).
  • أمريكان إكسبريس — 34 أو 37 · 15 خانة · CID (4، مطبوع في الواجهة).
  • ديسكفر — 6011 و644–649 و65 و622126–622925 · 16 أو 19 خانة · CID (3).
  • JCB — 3528–3589 · 16 إلى 19 خانة · CAV2 (3).
  • داينرز كلوب — 300–305 و3095 و36 و38–39 · 14 أو 16 أو 19 خانة · CVV (3).
  • يونيون باي — 62 و81 · 16 إلى 19 خانة · CVN2 (3).
  • مايسترو — 5018 و5020 و5038 و56–59 و6304 و6759 و6761–6763 · 12 إلى 19 خانة · CVV (3)، وقد يغيب.

الفخ 1: سلسلة ماستركارد الثانية

أضافت ماستركارد 2221–2720 في 2016 لتخفيف الضغط عن 51–55. التعابير النمطية القديمة التي تفحص ^5[1-5] فقط ترفض بصمت ملايين البطاقات الصالحة. أسئلة ماستركارد عن سلسلة 2 تصف الطرح؛ اختبرها برقم Stripe ‏2223 0031 2200 3222 في أرقام الاختبار.

الفخ 2: النطاقات المشتركة

622126–622925 يخص ديسكفر ويونيون باي معًا عبر اتفاقية بين الشبكتين، ومايسترو يتداخل مع عدة نطاقات أعلاه. فضّل دائمًا المطابقة الأكثر تحديدًا (أطول بادئة) بدل أول تعبير نمطي يمرّ.

الفخ 3: افتراض 16 خانة

أمكس 15، وداينرز غالبًا 14، ومايسترو قد تكون 12. المدقّقات التي ترمّز 16 تفشل مع عملاء حقيقيين؛ انظر لماذا تتراوح أرقام البطاقات بين 12 و19 خانة.

اكتشاف البادئة ميزة لسهولة الاستخدام لا ضابط أمني. يخبرك أي شعار تعرض؛ ولا يخبرك إن كانت البطاقة حقيقية — ذلك شأن التفويض وحده.

أسئلة شائعة

بأي رقم تبدأ بطاقات فيزا؟

كل بطاقات فيزا تبدأ بالخانة 4 وتتكون من 13 أو 16 أو 19 خانة.

لماذا يرفض مدقّقي بطاقة ماستركارد تبدأ بـ2؟

لأنه سابق لتوسعة سلسلة 2 في 2016. تستخدم ماستركارد الآن 2221–2720 إضافة إلى 51–55.

Educational content — not legal or financial advice. Open the interactive Check Digit Lab →