networks · 2025-05-05 · 4 min read

Why card numbers are 12 to 19 digits long (and 16 is not a rule)

ISO/IEC 7812 allows up to 19 digits. Most cards use 16, but assuming 16 breaks Amex, Diners and many Maestro cards — one of the most common validation bugs in the wild.

16 is common — not universal.
16 is common — not universal. — © Tima Miroshnichenko · Pexels

The ISO/IEC 7812-1 standard sets a maximum of 19 digits for a PAN: up to 8 for the issuer identifier, a variable-length account identifier, and one check digit. There is no rule that says 16.

Lengths by network

  • Visa — 13 (legacy), 16, and 19 for some newer programs.
  • Mastercard — 16 only.
  • American Express — always 15.
  • Diners Club — 14 (classic), 16 (Discover-processed) or 19.
  • Discover — 16 or 19.
  • JCB — 16 to 19.
  • UnionPay — 16 to 19.
  • Maestro — anywhere from 12 to 19.

The prefix cheat-sheet pairs each range with its lengths, and the ranges table applies them live.

Validating length correctly

  • Detect the brand first, then check the length against that brand's allowed set.
  • If the brand is unknown, accept 12–19 and let Luhn and the gateway decide.
  • Set input maxlength to 23 (19 digits plus up to 4 spaces) — see formatting as you type.
  • Treat 'too short' as incomplete (no error yet) and only 'wrong length for brand' as an error, per the error-message guidelines.
Hard-coding 16 as the only valid length rejects every American Express customer — a bug still shipped by surprisingly large sites.
Hard-coding 16 breaks Amex, Diners and Maestro.
Hard-coding 16 breaks Amex, Diners and Maestro.

Keywords: card number length, how many digits credit card, Amex 15 digits, Diners 14 digits, Maestro length, ISO 7812 length

Frequently asked questions

How many digits are on an American Express card?

Fifteen, grouped 4-6-5, with a 4-digit security code on the front.

Can a credit card number have 19 digits?

Yes. Visa, Discover, JCB, UnionPay, Diners Club and Maestro all issue 19-digit cards in some programs.

On this site

External references

Related articles

لماذا تتراوح أرقام البطاقات بين 12 و19 خانة (و16 ليست قاعدة) — النسخة العربية

يسمح ISO/IEC 7812 بما يصل إلى 19 خانة. تستخدم معظم البطاقات 16، لكن افتراض 16 يكسر أمكس وداينرز وكثيرًا من بطاقات مايسترو — من أكثر أخطاء التحقق شيوعًا في الواقع.

يحدّد معيار ISO/IEC 7812-1 حدًا أقصى 19 خانة لـرقم البطاقة: حتى 8 لمعرّف المُصدِر، ومعرّف حساب متغيّر الطول، وخانة تحقق واحدة. لا توجد قاعدة تقول 16.

الأطوال حسب الشبكة

  • فيزا — 13 (قديم) و16 و19 لبعض البرامج الأحدث.
  • ماستركارد — 16 فقط.
  • أمريكان إكسبريس — دائمًا 15.
  • داينرز كلوب — 14 (كلاسيكي) أو 16 (معالَجة عبر ديسكفر) أو 19.
  • ديسكفر — 16 أو 19.
  • JCB — 16 إلى 19.
  • يونيون باي — 16 إلى 19.
  • مايسترو — أي شيء من 12 إلى 19.

الورقة المرجعية للبادئات تقرن كل نطاق بأطواله، وجدول النطاقات يطبّقها حيًّا.

التحقق من الطول بشكل صحيح

  • اكتشف العلامة أولًا ثم افحص الطول مقابل مجموعة تلك العلامة المسموحة.
  • إن كانت العلامة مجهولة اقبل 12–19 ودع لون والبوابة يقرّران.
  • اضبط maxlength للحقل على 23 (19 خانة زائد حتى 4 مسافات) — انظر التنسيق أثناء الكتابة.
  • عامل «قصير جدًا» على أنه غير مكتمل (لا خطأ بعد) و«طول خاطئ للعلامة» فقط كخطأ، وفق إرشادات رسائل الخطأ.
ترميز 16 بوصفه الطول الصالح الوحيد يرفض كل عميل أمريكان إكسبريس — خطأ ما زالت تشحنه مواقع كبيرة بشكل مفاجئ.

أسئلة شائعة

كم خانة في بطاقة أمريكان إكسبريس؟

خمس عشرة، مجمّعة 4-6-5، مع رمز أمان من 4 خانات في الواجهة.

هل يمكن أن يكون رقم بطاقة الائتمان 19 خانة؟

نعم. فيزا وديسكفر وJCB ويونيون باي وداينرز كلوب ومايسترو جميعها تُصدر بطاقات من 19 خانة في بعض البرامج.

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