npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@banshee.com/iso7813parser

v1.0.7

Published

ISO/IEC 7813 magnetic stripe card data parser using Chevrotain

Readme

@banshee.com/iso7813Parser

A TypeScript library for parsing ISO/IEC 7813 magnetic stripe card data, built with Chevrotain.

Supports Track 1 (IATA, alphanumeric) and Track 2 (ABA, numeric) formats.

Installation

pnpm add @banshee.com/iso7813Parser

Usage

import { parse, parseTrack1, parseTrack2 } from "@banshee.com/iso7813Parser";

// Auto-detect track type from the input
const result = parse("%B4111111111111111^DOE/JOHN^2512101?");

if (result.data?.track === 1) {
  console.log(result.data.pan);            // "4111111111111111"
  console.log(result.data.name.surname);   // "DOE"
  console.log(result.data.name.givenName); // "JOHN"
  console.log(result.data.formatCode);     // "B"
}

// Or parse a specific track directly
const t2 = parseTrack2(";4111111111111111=2512101?");
console.log(t2.data?.pan);                     // "4111111111111111"
console.log(t2.data?.expirationDate?.month);   // 12
console.log(t2.data?.serviceCode);             // "101"

API

parse(input: string): ParseResult<Track1Data | Track2Data>

Auto-detects the track format by inspecting the first character (% → Track 1, ; → Track 2) and parses accordingly. Throws if the input is empty or starts with an unrecognized character.

parseTrack1(input: string): ParseResult<Track1Data>

Parses ISO/IEC 7813 Track 1 (IATA) magnetic stripe data.

parseTrack2(input: string): ParseResult<Track2Data>

Parses ISO/IEC 7813 Track 2 (ABA) magnetic stripe data.

ParseResult<T>

interface ParseResult<T> {
  data?: T;              // Parsed data (undefined if parsing failed)
  lexErrors: ILexingError[];        // Lexer errors
  parseErrors: IRecognitionException[]; // Parser errors
}

Track1Data

interface Track1Data {
  track: 1;
  formatCode: string;        // Typically "B" for banking
  pan: string;               // Primary Account Number (up to 19 digits)
  name: CardholderName;      // Parsed cardholder name
  expirationDate?: ExpirationDate;
  serviceCode?: string;      // 3-digit service code
  discretionaryData?: string;
  lrc?: string;              // Longitudinal Redundancy Check
}

Track2Data

interface Track2Data {
  track: 2;
  pan: string;
  expirationDate?: ExpirationDate;
  serviceCode?: string;
  discretionaryData?: string;
  lrc?: string;
}

CardholderName

interface CardholderName {
  raw: string;          // Raw name as encoded (e.g. "DOE/JOHN.MR")
  surname: string;
  givenName?: string;
  title?: string;       // e.g. "MR", "DR"
}

ExpirationDate

interface ExpirationDate {
  raw: string;   // 4-digit YYMM string
  year: number;  // Two-digit year
  month: number; // 1–12
}

Track Formats

Track 1 (IATA)

%B4111111111111111^DOE/JOHN^25121011234?
│ │               │        │    │  │   │
SS FC  PAN        FS Name  FS ED SC DD ES
  • Up to 79 alphanumeric characters
  • Start sentinel: %, End sentinel: ?, Field separator: ^

Track 2 (ABA)

;4111111111111111=25121011234?
│               │    │  │   │
SS    PAN       FS ED SC DD ES
  • Up to 40 numeric characters
  • Start sentinel: ;, End sentinel: ?, Field separator: =

License

Apache 2.0