8-Digit BIN and IIN Explained: ISO/IEC 7812, Luhn Checks and How Card Routing Uses BIN Tables
Most payment code still contains a line like bin = pan[:6]. Since April 2022 that line has been quietly wrong for a growing share of cards. The card networks moved to the 8-digit BIN defined in the 2017 edition of ISO/IEC 7812-1, and a six-character substring no longer identifies the issuer reliably. The failure is rarely loud. A fraud rule fires on the wrong population, a debit card is treated as credit and routed to the expensive network, or a report merges two issuers that now share a six-digit prefix.
This matters now because the population of eight-digit issuing BINs keeps growing every year, and U.S. debit routing and interchange rules are back in court. Both trends raise the cost of a wrong lookup. This guide treats the bank identification number as what it has become: a variable-length range key, not a fixed prefix.
What this covers: PAN anatomy under ISO/IEC 7812-1:2017, the Luhn algorithm with a worked example, PCI DSS masking and truncation, what BIN attributes drive in routing, and runnable Python plus a SQL schema for a range-based BIN table.
Disclaimer: this is a systems and architecture explainer, not legal, compliance or financial advice. Confirm brand rules with your acquirer and PCI decisions with your QSA.
Context and Background
Every payment card number is a primary account number (PAN). Its leading digits identify the issuer, and the industry uses two names for that prefix. The standards term is issuer identification number (IIN), defined in ISO/IEC 7812-1. The older, informal term is bank identification number (BIN), which networks, processors and merchants still use daily. In practice, “BIN” and “IIN” refer to the same leading digits, although networks also use “BIN” for internal identifiers such as acquiring BINs.
The registration authority for IINs is the American Bankers Association, which has administered the register on behalf of ISO. Wikipedia’s summary of the standard notes that CUSIP Global Services took over administrative responsibility for the ABA in February 2024. Card networks then manage large blocks of that space. Visa, for example, controls ranges beginning with 4, and Mastercard controls 51–55 plus the 2-series range 222100–272099, which Braintree’s developer blog documented as issuable from early 2017.
The reason for the change was exhaustion. A six-digit IIN gives one million possible prefixes across all industries, and far fewer within the leading digits that banks use. Card programs multiplied: prepaid, virtual cards for commercial payments, fintech issuing on sponsor banks, and network tokens that each need their own ranges. Mastercard’s own 2021 guidance on the migration noted that emerging technologies such as tokenization had increased demand for BINs.
ISO responded with the fifth edition, ISO/IEC 7812-1:2017. Its foreword states that it “revised the length of an IIN to 8 digits (from 6 digits)” and revised the minimum PAN length to 10 digits. Visa and Mastercard both announced adoption in 2017 and set April 2022 as the date by which acquirers and processors had to support eight-digit issuing BINs. If your platform issues cards, the issuing side of this story is covered in our deep dive on card issuing processor architecture, BIN sponsors and JIT funding. This post stays on the consuming side: the merchant, PSP, acquirer and orchestration systems that read a PAN and must decide what it is.
One fact surprises many engineers. The migration did not change the length of most cards. Visa’s merchant FAQ is explicit that “the PAN length is not changing with the BIN length expansion.” A 16-digit Visa card stays 16 digits. What changes is how many of those digits belong to the issuer, so the account identifier shrinks from nine digits to seven inside the same 16-digit envelope.
How the 8-Digit BIN Changes PAN Structure and Routing
Direct answer: An 8-digit BIN is an issuer identification number that uses the first eight digits of a card number, as defined in ISO/IEC 7812-1:2017. The PAN length usually stays at 16 digits, so the account portion shrinks. Systems must look the PAN up against ranges in a BIN table instead of slicing the first six digits.

Figure 1: Anatomy of a PAN under ISO/IEC 7812-1:2017, comparing the legacy six-digit IIN layout with the eight-digit layout inside the same 16-digit card number.
The diagram shows a single PAN split three ways. The issuer identification number occupies the leading positions, six digits in the legacy layout and eight in the current one. The individual account identifier fills the middle. The final digit is always a Luhn check digit computed over everything before it. Because the total length is fixed by the card program, every digit the IIN gains is a digit the account identifier loses.
The PAN has three parts, and only one of them is fixed in position
ISO/IEC 7812-1 defines the PAN as the IIN, followed by an individual account identification number, followed by a check digit. The maximum PAN length is 19 digits. The international IIN register procedure published by Pay.UK spells out the arithmetic: an eight-digit IIN, up to 10 digits of account identification, and one Luhn check digit.
That gives you the capacity trade-off in plain numbers. With a six-digit IIN and a 16-digit PAN, the account identifier has nine digits, so one IIN can address one billion accounts. With an eight-digit IIN and a 16-digit PAN, the account identifier has seven digits, so one IIN addresses ten million accounts. The issuer gives up 99 percent of the account space per prefix in exchange for one hundred times as many prefixes. For a fintech program that needs a dedicated BIN for one product, ten million accounts is ample.
The first digit was historically called the major industry identifier (MII): 4 and 5 for banking and financial, 3 for travel and entertainment, 7 for petroleum, 9 for national standards bodies. One detail most explainers miss is that the 2017 edition’s foreword says the formal MII definition and its outline were removed from the standard. The Pay.UK register procedure still describes the first digit in MII terms, and engineers still use the concept informally. Treat the first digit as a hint, never as a routing key.
Six-digit and 8-digit BINs coexist, but never on the same prefix
The migration did not convert every existing BIN. Visa’s merchant FAQ states that 6-digit BINs “will continue to exist alongside eight-digit BINs for the foreseeable future.” What changed is that new issuing BINs are assigned at eight digits, and an issuer may split an existing 6-digit BIN into up to one hundred eight-digit children.
Visa adds a critical rule: one prefix cannot be both lengths at once. When a 6-digit BIN is split, it “will cease to exist as a 6-digit BIN.” That rule is the foundation of correct lookup design. For any given PAN, exactly one BIN definition applies, and the BIN table tells you whether it is six or eight digits long. You cannot infer the length from the PAN itself.
This is why pan[:6] fails, and why pan[:8] fails too. Slicing eight digits from a card issued on a legacy 6-digit BIN gives you a key that does not exist in any table. Slicing six digits from a card on an 8-digit BIN gives you a key that may map to a different issuer, or to nothing at all after the parent was retired.
BIN tables are really account-range tables
The networks never distributed “BIN to issuer” maps as simple prefix dictionaries. They distribute account ranges: a low PAN and a high PAN, with attributes attached. Visa’s merchant FAQ recommends the nine-digit account range for processing, and tokens continue to be managed at the nine-digit account-range level. Mastercard’s 2021 guidance required acquirers and their processors to support 11-digit account ranges by April 2022.
So the honest data model is not “BIN equals first N digits.” It is “find the account range that contains this PAN.” A range can be wider than a BIN (rare) or narrower than a BIN (common, because issuers carve a BIN into product-specific ranges). The BIN length becomes an attribute of the matching row, which you need for truncation, display and reporting, but it is not the key you search on.
Here is the architectural thesis of this post. Treat BIN resolution as a range-containment query over a versioned, multi-source table, and return the most specific match. Do that once, in one service, and every downstream consumer stops carrying its own slicing logic. Fraud, routing, reporting and tokenization then all agree on what a card is.
The Luhn Algorithm, Worked End to End
Before any BIN lookup, a well-designed pipeline runs the cheapest possible filter: the Luhn check. The Luhn algorithm, also called “mod 10” or “double-add-double,” is specified in Annex B of ISO/IEC 7812-1. It detects every single-digit typo and most adjacent transpositions. It is not a security control, and it says nothing about whether an account exists.
Validating a full PAN
To validate, walk the digits from right to left. Leave the rightmost digit (the check digit) alone, double every second digit, and if a doubled value exceeds 9, subtract 9. Sum everything. The PAN is valid if the total is divisible by 10.
Take the published Visa test number 4111 1111 1111 1111. Counting from the right, the undoubled positions hold eight 1s, which sum to 8. The doubled positions hold seven 1s and the leading 4. The seven 1s double to 2 each, giving 14, and the 4 doubles to 8. The total is 8 + 14 + 8 = 30, which ends in zero, so the number passes.
Now change the last digit, giving 4111 1111 1111 1112. The total becomes 31 and the check fails. That is the whole value proposition: a single mistyped digit always changes the total by a non-multiple of 10, so the check catches it before the PAN ever leaves the browser.
Computing a check digit
Issuers and test-data generators run the algorithm the other way. Take the first 15 digits of the published Mastercard test number, 555555555555444, and compute the missing check digit. Because the check digit will occupy the rightmost position, doubling now starts with the rightmost payload digit.
| Payload position from right | Digits | Doubled? | Contribution |
|---|---|---|---|
| 1, 3 | 4, 4 | Yes | 8 + 8 = 16 |
| 5, 7, 9, 11, 13, 15 | six 5s | Yes | 10 becomes 1, six times = 6 |
| 2 | 4 | No | 4 |
| 4, 6, 8, 10, 12, 14 | six 5s | No | 30 |
| Total | 56 |
The check digit is (10 − 56 mod 10) mod 10 = 4. Appending it gives 5555 5555 5555 4444, which is exactly the Mastercard test number Stripe publishes. The same procedure works for 15-digit American Express numbers and 19-digit UnionPay numbers, because Luhn is length-agnostic.
What Luhn does and does not buy you
Luhn catches the classic data-entry errors. It does not catch every transposition: swapping 0 and 9 in adjacent positions leaves the sum unchanged, because 0 doubles to 0 and 9 doubles to 9. It also offers zero protection against card-testing bots, which simply generate Luhn-valid numbers inside a known BIN range. A Luhn pass means “syntactically plausible,” nothing more.
Some programs historically issued numbers without a valid Luhn digit, and certain private-label or closed-loop cards still do. A strict global Luhn gate will reject them. The safer pattern is to make the Luhn requirement a per-range attribute in the BIN table, defaulting to required.
Walk-Through: Building a Range-Based BIN Lookup
This section turns the thesis into working code. The goal is a lookup that accepts any PAN from 10 to 19 digits, validates it, and returns the most specific matching range with its attributes. Every number in the examples is a published test PAN from Stripe’s testing documentation, and the attributes attached to them are illustrative, not real issuer data.

Figure 2: The authorization-time BIN lookup pipeline, from PAN capture through Luhn validation, range lookup and attribute fan-out to routing, fraud and compliance decisions.
The pipeline runs in a fixed order because each step is cheaper than the next. Length and Luhn checks are pure CPU and reject garbage instantly. The range lookup is an in-memory index query that returns one row. That row then fans out to independent consumers: the router reads brand, funding source and regulated status, fraud reads country and product, and the vault reads the BIN length to decide what it may store in clear.
Step 1: normalize keys so ranges of any length compare correctly
The trick that makes mixed six-digit, eight-digit, nine-digit and 11-digit ranges coexist is padding. Right-pad every bound and every PAN to 19 digits, the ISO maximum. The low bound of a prefix is padded with zeros and the high bound with nines. Now a 16-digit PAN and a 19-digit PAN sort on one numeric axis, and a prefix of any length becomes an inclusive interval.
For example, the six-digit prefix 424242 becomes the interval from 4242420000000000000 to 4242429999999999999. The eight-digit prefix 40000566 becomes a narrower interval nested inside the six-digit space of 400005. Nesting is exactly what happens when an issuer splits a BIN or carves out an account range, so the index must handle it.
Step 2: a Luhn validator and a centered interval tree
The code below implements both functions in standard-library Python. The interval tree handles nested and overlapping ranges, which a simple sorted list with binary search cannot do once ranges nest. Lookup returns the narrowest matching range, so an eight-digit child always beats its six-digit parent.
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional
PAN_WIDTH = 19 # ISO/IEC 7812-1 maximum PAN length
def luhn_valid(pan: str) -> bool:
"""True if the digit string passes the Luhn mod-10 check."""
if not pan.isdigit() or not 10 <= len(pan) <= 19:
return False
total = 0
for i, ch in enumerate(reversed(pan)):
d = ord(ch) - 48
if i % 2 == 1: # every second digit from the right
d *= 2
if d > 9:
d -= 9
total += d
return total % 10 == 0
def luhn_check_digit(payload: str) -> str:
"""Check digit to append to a payload (doubling starts at its last digit)."""
total = 0
for i, ch in enumerate(reversed(payload)):
d = ord(ch) - 48
if i % 2 == 0:
d *= 2
if d > 9:
d -= 9
total += d
return str((10 - total % 10) % 10)
def pan_key(pan: str) -> int:
"""Right-pad to 19 digits so ranges of any prefix length compare numerically."""
return int(pan.ljust(PAN_WIDTH, "0"))
def range_for_prefix(prefix: str) -> tuple[int, int]:
return int(prefix.ljust(PAN_WIDTH, "0")), int(prefix.ljust(PAN_WIDTH, "9"))
@dataclass(frozen=True)
class BinRange:
low: int # inclusive, 19-digit padded
high: int # inclusive, 19-digit padded
bin_length: int # 6 or 8
brand: str
funding: str # credit | debit | prepaid
country: str # ISO 3166-1 alpha-2
regulated: Optional[bool] = None
pan_lengths: tuple = (16,)
@property
def width(self) -> int:
return self.high - self.low
@dataclass
class _Node:
center: int
here: list
left: Optional["_Node"] = None
right: Optional["_Node"] = None
class IntervalTree:
"""Centered interval tree: O(n log n) build, O(log n + k) stabbing query."""
def __init__(self, ranges: list[BinRange]):
self.root = self._build(ranges)
def _build(self, ranges):
if not ranges:
return None
points = sorted(p for r in ranges for p in (r.low, r.high))
center = points[len(points) // 2]
here = [r for r in ranges if r.low <= center <= r.high]
left = [r for r in ranges if r.high < center]
right = [r for r in ranges if r.low > center]
return _Node(center, here, self._build(left), self._build(right))
def stab(self, key: int) -> list[BinRange]:
hits, node = [], self.root
while node:
hits.extend(r for r in node.here if r.low <= key <= r.high)
if key < node.center:
node = node.left
elif key > node.center:
node = node.right
else:
break
return hits
def lookup(tree: IntervalTree, pan: str) -> Optional[BinRange]:
if not luhn_valid(pan):
return None
hits = [r for r in tree.stab(pan_key(pan)) if len(pan) in r.pan_lengths]
# Most specific range wins: an 8-digit child beats its 6-digit parent.
return min(hits, key=lambda r: r.width, default=None)
if __name__ == "__main__":
# Published test PANs only; attributes are illustrative, not issuer data.
rows = [
BinRange(*range_for_prefix("424242"), 6, "visa", "credit", "US", False),
BinRange(*range_for_prefix("400005"), 6, "visa", "credit", "US", False),
BinRange(*range_for_prefix("40000566"), 8, "visa", "debit", "US", True),
BinRange(*range_for_prefix("222300"), 6, "mastercard", "credit", "US"),
BinRange(*range_for_prefix("62055000"), 8, "unionpay", "debit", "CN",
pan_lengths=(16, 17, 18, 19)),
]
tree = IntervalTree(rows)
for pan in ["4242424242424242", "4000056655665556", "2223003122003222",
"6205500000000000004", "4242424242424241"]:
hit = lookup(tree, pan)
print(pan[:8], "->", hit and (hit.brand, hit.funding, hit.bin_length))
print("check digit:", luhn_check_digit("555555555555444"))
Running it prints the expected results. The Visa debit test card 4000056655665556 resolves to the illustrative eight-digit debit range even though a six-digit credit range for 400005 also contains it, because the narrower range wins. The 19-digit UnionPay test card resolves because its range declares 19 as a valid length. The last PAN, 4242424242424241, fails Luhn and returns nothing, and the check-digit helper prints 4.
Step 3: why an interval tree, and when you do not need one
If your source data guarantees non-overlapping ranges, a sorted array of low bounds plus binary search is simpler and faster. You find the greatest low bound at or below the key and check the matching high bound. That is O(log n) with excellent cache behavior.
Real BIN data rarely gives you that guarantee. You merge a network file, a processor table and a commercial database, and they disagree about boundaries. Issuers split 6-digit BINs into eight-digit children while the parent row lingers in a stale feed. Overlap is the normal case, so you need either an interval tree or an explicit flattening step that resolves nesting at load time. The tree keeps the raw rows auditable, which helps when you have to explain to a merchant why a card was classified as debit.
On capacity, a full Visa dataset is not small. Visa’s developer documentation for the BIN Attribute Sharing Service (VBASS) says the full dataset takes roughly 12,000 paginated JSON calls or about 325 calls through the file-transfer API with files of roughly 5 MB each. Even at hundreds of thousands of ranges, the in-memory tree fits comfortably in a few hundred megabytes of a single process. The real cost is the refresh pipeline, not the lookup.
Step 4: a SQL schema for the BIN table
The in-memory index should be a projection of a durable, versioned table. The schema below is PostgreSQL. Note the key types: a 19-digit padded key can exceed the signed 64-bit maximum of 9,223,372,036,854,775,807, so BIGINT overflows for padded keys above that value, which includes some prefixes beginning with 9. NUMERIC(19,0) avoids the trap.
CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE TABLE bin_source (
source_id SMALLINT PRIMARY KEY,
name TEXT NOT NULL, -- e.g. network file, processor, vendor
trust_rank SMALLINT NOT NULL -- lower wins on conflict
);
CREATE TABLE bin_table_version (
version_id BIGSERIAL PRIMARY KEY,
loaded_at TIMESTAMPTZ NOT NULL DEFAULT now(),
status TEXT NOT NULL CHECK (status IN ('staged','active','retired')),
row_count INTEGER,
checksum TEXT
);
CREATE TABLE bin_range (
version_id BIGINT NOT NULL REFERENCES bin_table_version,
source_id SMALLINT NOT NULL REFERENCES bin_source,
low_key NUMERIC(19,0) NOT NULL, -- right-padded with 0s to 19 digits
high_key NUMERIC(19,0) NOT NULL, -- right-padded with 9s to 19 digits
bin_length SMALLINT NOT NULL CHECK (bin_length IN (6, 8)),
prefix_len SMALLINT NOT NULL, -- 6, 8, 9, 11 ... granularity of this row
pan_lengths SMALLINT[] NOT NULL, -- e.g. {16} or {16,17,18,19}
brand TEXT NOT NULL,
funding_source TEXT NOT NULL CHECK (funding_source IN ('credit','debit','prepaid','charge','deferred_debit','unknown')),
product_code TEXT,
is_commercial BOOLEAN,
issuer_name TEXT,
issuer_country CHAR(2),
billing_ccy CHAR(3),
durbin_regulated BOOLEAN, -- NULL means unknown, never assume
luhn_required BOOLEAN NOT NULL DEFAULT TRUE,
is_token_range BOOLEAN NOT NULL DEFAULT FALSE,
pan_range NUMRANGE GENERATED ALWAYS AS (numrange(low_key, high_key, '[]')) STORED,
CHECK (low_key <= high_key),
-- No two rows from one source at the same granularity may overlap in a version.
EXCLUDE USING gist (version_id WITH =, source_id WITH =,
prefix_len WITH =, pan_range WITH &&)
);
CREATE INDEX bin_range_lookup ON bin_range USING gist (version_id, pan_range);
The exclusion constraint encodes the Visa rule that a prefix cannot be two lengths at once, scoped to a single source and granularity. Nested rows at different granularities are allowed, because that is how account ranges sit inside BINs. Cross-source conflicts are allowed too, and resolved by trust_rank when the version is built.
A lookup in SQL is then a containment query ordered by specificity: filter on the active version, pan_range @> :key, and order by prefix_len DESC, trust_rank ASC, taking one row. You will rarely run that per authorization; it exists for audits, back-office tooling and to build the in-memory index.
BIN Table Routing: What the Attributes Actually Drive
A BIN table is only as valuable as the decisions it feeds. The attributes that matter are surprisingly consistent across networks. Visa’s VBASS documentation lists them plainly: account range minimum and maximum, BIN length, issuer country, product platform (consumer or commercial), product ID, account funding source (credit, debit or prepaid), combo-card indicator, and an exempt or non-exempt flag for regulated debit. Each one changes money movement somewhere.

Figure 3: BIN table ingestion. Network, processor and commercial sources are normalized, conflict-checked and published as a versioned range index that routing, fraud, vault and reporting services consume.
The figure shows why ownership matters. Three kinds of source arrive on different schedules and with different trust levels. A normalization stage converts each one into padded ranges, a validation stage checks overlaps and diffs against the active version, and only then does a new version get promoted. Consumers read one active version, so a bad file can be rolled back by flipping a pointer.
Brand and network selection
The first job of a BIN table is to answer “which network?” For most cards the leading digits make that obvious, but not for all. Co-badged cards carry two brands, such as a domestic scheme plus an international one, or a global brand plus a U.S. debit network. The BIN table tells the router which networks a card can travel on. The router then chooses, subject to brand rules and local regulation. Our guide to ISO 8583 vs ISO 20022 card messaging shows where that decision surfaces in the authorization message itself.
Funding source, regulated status and least-cost routing
For U.S. debit, the funding-source and regulated flags are where BIN accuracy turns directly into cost. Regulation II, which implements the Durbin Amendment, does two things. It caps interchange on debit cards from issuers that, with affiliates, hold at least $10 billion in assets, and it requires issuers to enable at least two unaffiliated networks so merchants can choose the route.
The Federal Reserve’s October 2022 final rule clarified that the two-network requirement covers card-not-present transactions, effective July 1, 2023. That made least-cost routing a realistic option for e-commerce debit, not just in-store PIN debit. A router can only exploit that choice if it knows the card is debit, knows it is regulated or exempt, and knows which unaffiliated networks are enabled on it. All three facts come from the BIN or account-range attributes. The economics behind that decision are covered in our analysis of interchange fees and least-cost routing.
The legal ground under the fee cap is shifting. The Federal Reserve’s current cap is 21 cents plus 5 basis points, with an extra cent for issuers meeting fraud-prevention standards. In 2023 the Fed proposed lowering it to 14.4 cents plus 4 basis points with a 1.3-cent fraud adjustment, but has not adopted that proposal. In August 2025 the U.S. District Court for North Dakota vacated the fee standard in Corner Post v. Board of Governors, and on October 26, 2026 the Eighth Circuit affirmed. According to Venable’s November 2026 analysis, the vacatur takes effect only when the mandate issues, so current fees are not immediately changed. A parallel case, Linney’s Pizza, was argued in the Sixth Circuit on October 22, 2026 after a district court there upheld Regulation II.
For a systems team, the lesson is not to predict the outcome. It is to make sure your regulated flag is accurate, sourced and versioned, because whatever fee schedule emerges will still key off it. A router that hard-codes “all debit is regulated” will misprice exempt cards under any regime.
Country, product and commercial flags
Issuer country drives cross-border fees, currency conversion offers, sanctions screening and some fraud rules. Product and commercial flags drive Level 2 and Level 3 data requirements, which can unlock lower commercial interchange when the merchant sends enhanced line-item data. Merchant category codes interact with these attributes in rewards and interchange tables, which our guide to merchant category codes under ISO 18245 explains in detail.
Prepaid flags matter for risk. Many merchants restrict prepaid cards for subscriptions or high-value goods, and a stale BIN table that misclassifies a prepaid range as credit silently disables that control. Token-range flags matter too. A network token carries a token BIN from a token range, not the underlying card’s BIN, and tokens continue to be managed at the nine-digit account-range level according to Visa’s FAQ. A lookup that cannot tell a token range from a card range will misreport the issuer. Our explainer on network tokenization architecture covers how token requestors map tokens back to card attributes.
Where BIN data comes from
There are three source tiers, and they differ sharply in accuracy and licensing. First are network sources: Visa’s ARDEF-style account range files distributed to acquirers and processors, Visa’s VBASS service for registered merchants and partners, and Mastercard’s equivalent range data. Second are processor and acquirer tables, which repackage network data for their merchants. Third are commercial BIN databases sold or given away online.
Visa’s merchant FAQ is blunt about the third tier: “BIN tables purchased off the internet are only approximately 30% accurate.” It also warns that “the ARDEF table should never be used for routing purposes,” and that routing should use Visa-supplied routing tables. That is an important distinction. Attribute tables tell you what a card is, but the authoritative routing tables from your network or processor tell you where it may go. Mixing those roles is a classic source of bugs.
PCI DSS Masking and Truncation After the 8-Digit BIN
The BIN change collided with a long-standing PCI DSS convention: “first six, last four.” Systems display and store those ten digits so support agents can identify a card and reports can group by issuer. With 8-digit BINs, the first six digits no longer identify the issuer for some cards. The PCI Security Standards Council and the brands addressed this in two separate places, and the difference between them is subtle.
Masking controls what is displayed. In PCI DSS v4.0, Requirement 3.4.1, PCI SSC FAQ 1492 (April 2024) says that by default no more than the BIN and last four digits should be displayed, and anything more needs a documented, management-approved business justification. Mastercard’s October 2021 guidance put the display maximum at first six and last four without justification. Visa’s merchant FAQ says showing first eight and last four on receipts is allowed but requires documented business justification beyond first six and last four. The safe reading is that showing eight leading digits needs a written justification.
Truncation controls what is stored. PCI SSC FAQ 1091 lists the maximum digits retained by brand and PAN length. For 16-digit PANs on Discover, JCB, Mastercard, UnionPay and Visa, with either a six- or 8-digit BIN, the maximum is “first 8, any other 4,” and at least four digits must be removed. For 15-digit American Express PANs, it remains first six, last four. The PCI SSC blog from September 2021 adds that first six and last four “remains the common format accepted by all payment brands.”
There is a security subtlety here. A truncated 16-digit PAN with first eight and last four retained leaves only four unknown digits, and one of those is constrained by Luhn. That is roughly a thousand candidates, which is why FAQ 1091 and the PCI SSC blog warn against storing multiple truncated formats of the same PAN. If one table holds first eight, last four and another holds first six, last six, together they can expose far more. Mastercard’s guidance adds that if you need more than first eight and last four, truncation cannot satisfy the requirement, and you must use keyed hashes, index tokens or strong cryptography instead.
Hashing has its own date. FAQ 1492 notes that under Requirement 3.5.1.1, hashes generated after March 31, 2025 must be keyed cryptographic hashes. An unkeyed SHA-256 of a PAN is trivially brute-forced once the BIN is known, because the search space is only the account digits. For architectures that reduce scope by never holding the PAN, see our comparison of P2PE, E2EE, tokenization and encryption for PCI scope reduction.
Where Six-Digit Assumptions Break: An Audit Map
The April 2022 deadline applied to acquirers and processors. Merchants, PSPs and internal platforms were told to “assess” their systems, which in practice meant many did not. Four years later, six-digit assumptions still hide in places that were never part of the core authorization path. The audit below lists where to look and what the failure looks like.

Figure 4: Migration audit map. Each consumer that once sliced six digits must instead call the shared BIN resolution service and read the BIN length from the matching row.
The figure groups the breakage by consumer. On the left, legacy code paths slice six characters independently. In the middle, a single BIN resolution service becomes the only component allowed to interpret leading digits. On the right, each consumer reads the resolved attributes and the declared BIN length, so a future change in the standard is absorbed in one place.
Fraud and risk rules
Fraud teams love BIN rules: block this BIN, raise friction on that BIN, allow-list a corporate card BIN. Most rule engines store those as six-character strings. When an issuer splits a 6-digit BIN into eight-digit children, a block rule on the parent now covers every child, including clean programs that share nothing with the original problem. Conversely, an allow-list keyed on six digits may admit a newly carved high-risk prepaid range.
Velocity counters keyed on the first six digits suffer the same distortion. A card-testing attack against one eight-digit range gets diluted across up to one hundred sibling ranges in the counter, which delays the alert. Our guide to real-time fraud feature engineering with velocity counters covers the windowing side; the fix here is the key. Key BIN velocity on the resolved BIN with its declared length, never on a fixed slice.
Tokenization vaults and PAN storage
Vaults commonly store a “first six” column alongside the token so downstream systems can route and report without detokenizing. That column now carries either a complete 6-digit BIN or the first six digits of an 8-digit BIN, and nothing tells consumers which. If you widen it to eight digits, you change your truncation format and must confirm it against FAQ 1091 and your QSA. Store the resolved BIN length too, plus a reference to the BIN table version used at tokenization time.
Database column types are a quieter trap. A CHAR(6) BIN column or a fixed-width file layout with six positions will silently truncate an eight-digit value. Integer BIN columns drop leading zeros, which matters for any future range beginning with 0. Use a string type sized for at least eight digits and validate on write.
Reporting and analytics
Finance and analytics teams group revenue, approval rates and chargebacks by BIN. With a six-digit key, cards from different issuers or programs collapse into one bucket. Visa’s merchant FAQ states that reports must be updated to accommodate longer BINs. Approval-rate dashboards are especially sensitive, because a single poorly performing eight-digit range can hide inside a healthy six-digit aggregate. Our post on payment authorization rate optimization shows why issuer-level granularity drives retry strategy.
Routing and orchestration
The authorization message itself does not carry a BIN length field; Visa’s FAQ notes that BIN length is not in ISO messages. That means network processing is unaffected, but every routing decision you make before the message leaves your system depends on your own lookup. Smart routers that select an acquirer by issuer country, or cascade by funding source, inherit any error in the lookup. The orchestration patterns in our payment routing optimization guide all assume a correct BIN resolution step upstream.
Trade-offs, Gotchas, and What Goes Wrong
Freshness versus stability. Network files change constantly as issuers add ranges and split BINs. Refreshing daily keeps you accurate but raises the chance of promoting a corrupt file. The answer is staged versions with automated diff thresholds: if a new file removes more than a small, configured percentage of ranges, hold it for human review. The exact threshold is a local policy choice; there is no industry standard number.
Source conflicts are normal. Your network feed says a range is debit, your commercial database says credit. Do not average or guess. Rank sources explicitly, keep the losing value for audit, and alert when a high-trust and low-trust source disagree on a money-moving attribute such as funding source or regulated status.
Unknown is a valid answer. When the regulated flag is missing, the router must not default to “regulated” or “exempt.” Store NULL, route conservatively, and count how often it happens. A rising unknown rate is an early signal that your BIN data is stale.
Licensing limits what you can do. Network BIN data comes with terms of use. Visa’s VBASS, for example, requires registration and Visa approval. Some data may not be redistributed to third parties or used for purposes outside the agreement. Platforms that resell BIN lookups to their own merchants should read those terms before exposing an API.
PAN length is not a constant. UnionPay issues 19-digit cards, as Stripe’s 19-digit UnionPay test number reflects, and American Express uses 15. ISO allows 10 to 19. Hard-coding 16 in validation, masking or storage will reject legitimate cards. Make valid PAN lengths a per-range attribute.
Luhn is not identity. Card-testing bots generate Luhn-valid PANs inside real BIN ranges by the million. Passing Luhn and resolving to a real range proves nothing about the account. Pair BIN intelligence with velocity, device and authentication signals.
Test data leaks into production. Teams copy test PANs into seed data, then a production rule allows them. Keep published test PANs in a dedicated, non-production range set and fail closed if one appears in live traffic.
First digit heuristics rot. Code that maps 4 to Visa and 5 to Mastercard works until it meets the 2-series Mastercard range, a co-badged domestic scheme, or a private-label program. Use the table.
Practical Recommendations
Start by finding every place your code interprets leading digits. Search for [:6], substring(0, 6), LEFT(pan, 6), CHAR(6) and fixed-width file specs, and expect to find them in fraud rules, data warehouses, vaults, reconciliation jobs and customer-support tools. Each one is either a bug today or a bug when the next BIN split lands.
Then build one BIN resolution service and make it the only legitimate interpreter of leading digits. Give it a versioned range table, a padded numeric key, and a most-specific-match rule. Return the resolved BIN, its declared length, and the attributes with their source. Every consumer stores the BIN table version it used, so you can reproduce any past decision.
Treat PCI formats as a design decision, not a side effect. Pick one truncation format per PAN, document it, confirm it with your QSA, and never let two tables hold different truncations of the same card. If you need more than first eight and last four, switch to keyed hashes or tokens.
Finally, get your data from the right tier. Use network or processor data for anything that moves money, such as routing and regulated status. Use commercial databases, if at all, only for low-stakes enrichment, and label their output as such.
A short checklist:
- Replace every fixed-length slice with a call to one range-based BIN resolver.
- Store BIN length and BIN table version alongside any stored BIN.
- Use
NUMERIC(19,0)or padded strings for range keys, neverBIGINT. - Make Luhn requirement and valid PAN lengths per-range attributes.
- Key fraud velocity and rules on the resolved BIN, not on six digits.
- Allow
NULLfor regulated status and alert on rising unknown rates. - Confirm masking and truncation formats with your acquirer and QSA.
- Stage, diff and approve every BIN table refresh before promotion.
Frequently Asked Questions
What is an 8-digit BIN?
An 8-digit BIN is a bank identification number, formally an issuer identification number, made of the first eight digits of a payment card number. ISO/IEC 7812-1:2017 lengthened the IIN from six to eight digits because the six-digit space was running out. Visa and Mastercard required acquirers and processors to support eight-digit issuing BINs by April 2022. Most cards stay 16 digits long, so the extra issuer digits come out of the account identifier. Six-digit BINs still exist alongside them.
Is BIN the same as IIN?
Yes, for issuing purposes the terms are interchangeable. Issuer identification number is the formal term used by ISO/IEC 7812-1, while bank identification number is the older industry term still used by networks, processors and merchants. Both describe the leading digits of a primary account number that identify the card issuer. Networks also use “BIN” for some internal identifiers, such as acquiring BINs, which is why Visa reclassified six-digit acquiring numerics as Acquiring IDs during the migration.
How do I know if a card has a 6-digit or 8-digit BIN?
You cannot tell from the card number alone. The BIN length is a property of the issuer’s assignment, so you must look the PAN up in an authoritative BIN or account-range table that records the length. Visa provides this through its client directory and BIN Attribute Sharing Service, and processors expose it in their BIN tables. Visa also states that a single prefix cannot be both a six-digit and an 8-digit BIN at the same time, so exactly one definition applies.
Does the 8-digit BIN change PCI DSS truncation rules?
It changed which formats are acceptable, not the principle of storing as little as possible. PCI SSC FAQ 1091 allows at most the first eight and any other four digits for 16-digit PANs from Discover, JCB, Mastercard, UnionPay and Visa, whether the BIN is six or eight digits. American Express 15-digit PANs remain at first six, last four. Displaying more than the BIN and last four needs a documented business justification under Requirement 3.4.1. Confirm your format with your QSA.
What is the Luhn algorithm used for in card numbers?
The Luhn algorithm computes the final check digit of a card number, as specified in Annex B of ISO/IEC 7812-1. Starting from the right, every second digit is doubled, nine is subtracted from any result above nine, and all digits are summed. A valid number’s total is divisible by ten. It catches single-digit typos and most adjacent swaps before a payment is submitted. It is not a security control and cannot confirm that an account exists or has funds.
Why do payment routers need BIN tables?
Routers use BIN tables to learn what a card is before choosing where to send it. Attributes such as brand, debit or credit funding source, prepaid status, issuer country, commercial product and Durbin regulated status determine network eligibility, interchange cost, cross-border fees and risk rules. For U.S. debit, Regulation II requires issuers to enable two unaffiliated networks, so an accurate BIN table lets merchants choose the lower-cost route. A stale or inaccurate table misprices and misroutes transactions silently.
Further Reading
- Card issuing processor architecture: BIN sponsors, JIT funding and authorization — the issuer side of BIN assignment and how programs get their ranges.
- ISO 8583 vs ISO 20022 card messaging formats for authorization and clearing — where the PAN and routing decisions appear in the message.
- Merchant category codes explained under ISO 18245 — the merchant-side attribute that pairs with BIN attributes in interchange and fraud rules.
- Card authorization switch and issuer processing architecture — how the switch consumes account-range data in real time.
- PCI SSC FAQ 1091: acceptable formats for truncation of PANs — the authoritative truncation table by brand and PAN length.
- Visa: simplified requirements for eight-digit issuing BIN adoption — Visa’s April 2022 mandate and the Acquiring ID reclassification.
By Riju — about
