A payment card number, or PAN, is an identifier with structure: an issuer identification portion, an account portion and a final check digit. The first digit is the Major Industry Identifier, included inside the issuer identification number (IIN, also commonly called BIN). Reading the digits does not reveal the cardholder, security code, expiry or account balance.

Decompose one PAN under two explicit assumptions

Consider the synthetic fixture 4111111111111111. The boundary after the IIN is an input to this demonstration, not a fact discovered from that string:

CaseInput / conditionExpected result
iin-6Same PAN; assume IIN width 6{"account":"111111111","assumedIinWidth":6,"checkDigit":"1","iin":"411111","mii":"4"}
iin-8Same PAN; assume IIN width 8{"account":"1111111","assumedIinWidth":8,"checkDigit":"1","iin":"41111111","mii":"4"}

With a six-digit assumption, the account portion has nine digits. With an eight-digit assumption, it has seven. Both reconstructions produce the same 16-digit input. The first digit 4 is already present in the IIN; do not prepend it again.

export function splitPan(input, assumedIinWidth, profile) {
  const { status, digits } = normalizeInput(input);
  if (status !== 'ok' || digits.length < profile.minLength ||
      digits.length > profile.maxLength || ![6, 8].includes(assumedIinWidth)) {
    throw new TypeError('Use a local-profile PAN and an explicit IIN width of 6 or 8');
  }
  return {
    mii: digits[0], // Included in the IIN; not an extra digit before it.
    assumedIinWidth,
    iin: digits.slice(0, assumedIinWidth),
    account: digits.slice(assumedIinWidth, -1),
    checkDigit: digits.slice(-1)
  };
}

This function validates the input contract and separates positions. It does not verify an issuer allocation or require a passing checksum. A deliberately invalid check digit remains available for a negative test. The prefix lookup tool similarly reports local candidates rather than querying an issuing bank.

Verify the boundary and the check digit separately

Download the runnable PAN decomposition examples and extract the files. Use Node.js 22 or later:

node --test guide-examples.test.mjs
node guide-demo.mjs structure

The tests reconstruct iin + account + checkDigit, assert that it equals the normalized original, and reject an unspecified or unsupported width. A number with an inserted letter is rejected before slicing. This catches an easy implementation error: stripping a bad character first makes every later position appear correct.

The Luhn guide explains the final digit. A Luhn pass detects certain input errors; it does not confirm the IIN assumption, the account’s existence or the issuer’s acceptance. Use the card validator to see these independent results.

Length is a configured rule

The tool envelope is 12–19 digits. That is a local implementation choice, not a universal minimum attributed to ISO. Individual configured networks accept different subsets, including 17 and 18 digits where shown. The generator intentionally emits a smaller set for some networks:

NetworkGenerator outputValidator profile
American Express1515
Diners Club1414, 16, 19
Discover1616, 19
JCB1616, 17, 18, 19
Maestro16, 1912, 13, 14, 15, 16, 17, 18, 19
Mastercard1616
Troy1616
UnionPay16, 1916, 17, 18, 19
Visa1613, 16, 19

This table is rendered from the same JSON file supplied to the tools. A profile update changes the reference and is checked against the generated HTML. For example, the Troy fixture page uses the local 16-digit profile; it does not inherit every length in the global envelope.

Keep identifiers as strings

A PAN is not a quantity. JSON, CSV imports, spreadsheet cells and database adapters can all reinterpret digit strings. JavaScript Number loses exactness for sufficiently large integers, including the 19-digit fixture in the Visa transport test. Not every 19-digit value exceeds signed 64-bit capacity, so “19 digits always overflow” is also an incorrect rule.

For local tests, preserve strings and compare the original with the value read back from each boundary. Use the number generator for isolated format fixtures, with outbound payment requests disabled. A generated value is not guaranteed to be unassigned in the real world.

Display masking is not data removal

For a support view that only needs a suffix, display the last four digits and omit the rest. Do not put the full value in an HTML attribute, hidden field or telemetry event while merely replacing visible text with bullets.

PCI SSC distinguishes display masking from storage protection, and its guidance accommodates six- and eight-digit BINs. A generic “first six plus last four everywhere” rule is not sufficient. Storage truncation has separate brand-dependent rules; a CSS mask does not truncate a database value. See PCI SSC’s masking and truncation explanation and the developer data-flow guide before deciding what your application should retain.

Frequently Asked Questions

Where does the account identifier begin?
After the IIN. The example requires you to state an assumed width of six or eight digits. It cannot discover the actual allocation boundary from the number alone.
Is the industry digit separate from the IIN?
It is the first digit of the IIN, not an extra digit before it. Adding it again when reconstructing a PAN would duplicate a digit.
Does ISO require every PAN to have at least 12 digits?
This site uses 12–19 as its local tool envelope. That lower bound is not presented here as a universal ISO rule. Network-specific rules and the provider integration determine what your application supports.
Is a masked display the same as protected storage?
No. Display masking hides digits in one view; truncation removes selected digits from the retained value. Encryption and tokenization are different mechanisms. A masked screenshot says nothing about the original data in logs or databases.