All Tools
Tools/Track 1 & 2 Generator
💾
Card DataAvailable

Track 1 & 2 Generator

Generate ISO 7813 Track 1 and Track 2 magnetic stripe data from card details, with LRC computation and parse mode for decoding existing tracks.

Follows ISO/IEC 7813 · ISO/IEC 7811-2Track 1 format B, Track 2, LRC, service code·verified Oct 2026· double-checked Oct 2026— 6,000 generated and parsed tracks match an independent bit-level encoder; Python, Java and Rust snippets run against the tool

Use test data only. All calculations run locally in your browser — PayProbe never sees, transmits, or stores your PAN, CVV, keys, PINs, or cryptographic inputs. How we handle data →

</> Code Implementation
# Magnetic Stripe Track Generator — Track 1 & Track 2 with LRC
# No external dependencies required

def lrc_track1(track: str) -> str:
    """ISO 7811: XOR of 6-bit codes (ASCII - 0x20) from % to ? inclusive."""
    v = 0
    for c in track:
        v ^= (ord(c) - 0x20) & 0x3F
    return chr(v + 0x20)

def lrc_track2(track: str) -> str:
    """ISO 7811: XOR of 4-bit codes (; = B, = = D, ? = F) from ; to ? inclusive."""
    codes = {";": 0xB, "=": 0xD, "?": 0xF}
    v = 0
    for c in track:
        v ^= codes[c] if c in codes else int(c)
    return chr(0x30 + v)

def build_track1(pan: str, name: str, expiry: str,
                 service_code: str = "101", disc: str = "000000000") -> str:
    """Track 1: %B{PAN}^{NAME}^{EXPYYMM}{SC}{DISC}?{LRC}"""
    body = f"B{pan}^{name}^{expiry}{service_code}{disc}"
    return f"%{body}?" + lrc_track1(f"%{body}?")

def build_track2(pan: str, expiry: str,
                 service_code: str = "101", disc: str = "000000000") -> str:
    """;{PAN}={EXPYYMM}{SC}{DISC}?{LRC}"""
    body = f"{pan}={expiry}{service_code}{disc}"
    return f";{body}?" + lrc_track2(f";{body}?")

# Example
pan    = "4111111111111111"
name   = "DOE/JOHN"
expiry = "2512"   # YYMM
t1 = build_track1(pan, name, expiry)
t2 = build_track2(pan, expiry)
print(f"Track 1: {t1}")
print(f"Track 2: {t2}")
# Track 1: %B4111111111111111^DOE/JOHN^2512101000000000?;
# Track 2: ;4111111111111111=2512101000000000?8

What Track 1 and Track 2 data are

A magnetic-stripe card historically encodes its data on two tracks. Track 1 (alphanumeric, format B) holds the PAN, cardholder name, expiry, and service code; Track 2 (numeric) holds the PAN, expiry, service code and discretionary data in a more compact form and is the one most payment systems actually read. EMV chip and contactless transactions still carry an equivalent of Track 2 in tag 57, which is why understanding the layout — start sentinel, field separator, service code, end sentinel, LRC — remains relevant well beyond legacy stripes.

This tool builds correctly formatted track strings from synthetic test inputs so engineers can validate parsers, terminal builds, and message construction. The output mirrors the real encoding but is generated from fabricated, non-functional card data — it is not read from any physical card and cannot authorise a payment.

Reading the service code

The three-digit service code is worth knowing: the first digit signals interchange (international vs national, and whether the card is chip-capable), the second authorisation processing, and the third whether a PIN is required and how the card may be used. A service code beginning with 2 or 6 indicates a chip card (ISO/IEC 7813: “use IC where feasible”), so a chip-capable terminal should read the chip rather than the stripe. 101 is a plain stripe card with no restrictions; 201 the same card with a chip; a 9 in the first digit marks a test card.

Field rules and the LRC

Track 1 is at most 79 characters and Track 2 at most 40, counting the start sentinel (% / ;), the end sentinel ? and the LRC. The PAN is up to 19 digits, the name 2–26 characters (SURNAME/FIRSTNAME, upper case) and the expiry is YYMM. Track 2 is numeric, so the discretionary data here is digits only. The LRC (ISO/IEC 7811) is the XOR of the 6-bit (Track 1) or 4-bit (Track 2) character codes from the start to the end sentinel, which makes every bit column even; the LRC character carries its own odd-parity bit like every other character. Card readers check and strip the LRC, so track data from a terminal usually arrives without it.

Use only test data here — never encode or process a real card’s track data.

Something wrong or missing? Report a problem— we check reports against the specs and fix them.