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

usdriverslicenseparser

v1.1.3

Published

Parse AAMVA PDF417 barcode data from U.S. driver's licenses and ID cards (versions 03-10). Zero dependencies.

Readme

U.S. Drivers License Parser

GitHub license npm version

Parse PDF417 barcode data from U.S. driver's licenses and ID cards encoded according to AAMVA standards (versions 03 through 10).

Zero runtime dependencies. Works in Node.js and browsers.

Install

npm install usdriverslicenseparser

Quick start

import { parseLicense, parseLicenseSafe, parseAamvaDate, isExpired } from "usdriverslicenseparser";

const license = parseLicense(barcodeText);

console.log(license.FirstName);
console.log(license.LastName);
console.log(license.DocumentExpirationDate);
console.log(license.AamvaVersion);
console.log(isExpired(license));

const expiration = parseAamvaDate(license.DocumentExpirationDate);

For production UIs and APIs, prefer the non-throwing helper:

import { parseLicenseSafe } from "usdriverslicenseparser";

const result = parseLicenseSafe(barcodeText);

if (result.success) {
  console.log(result.data.FirstName);
} else {
  console.error(result.code, result.error);
}

API

Parsing

| Function | Description | |----------|-------------| | parseLicense(barcode) | Parse a raw barcode string. Throws typed errors on failure. | | parseLicenseSafe(barcode) | Same as above, but returns { success, data } or { success, error, code }. | | normalizeBarcode(barcode) | Normalize scanner output (\r\n\n, trim whitespace). Applied automatically by parseLicense. |

Helpers

| Function | Description | |----------|-------------| | parseAamvaDate(value) | Convert an AAMVA date string (MMDDYYYY) to a Date, or undefined if invalid. | | isExpired(license, asOf?) | Returns whether the license is expired, or undefined if no expiration date is present. | | getAge(license, asOf?) | Returns age in whole years, or undefined if date of birth is missing/invalid. | | isUnder21(license, asOf?) | Uses Under21Until when present, otherwise falls back to age. |

Metadata

Every successful parse includes header metadata:

| Field | Description | |-------|-------------| | AamvaVersion | AAMVA standard version (0310) | | IssuerId | Six-digit issuer identification number (IIN) | | JurisdictionVersion | Jurisdiction-specific version number |

Errors

| Error | Code | When | |-------|------|------| | MissingHeaderError | MISSING_HEADER | Barcode does not contain a valid @ANSI header | | UnsupportedVersionError | UNSUPPORTED_VERSION | AAMVA version is not supported | | MalformedBarcodeError | MALFORMED_BARCODE | DL subfile data could not be parsed |

Supported versions

| AAMVA Version | Parser | |---------------|--------| | 03, 04 | AAMVA 03 (combined DCT given name) | | 0507 | AAMVA 05 | | 08 | AAMVA 08 | | 09 | AAMVA 09 | | 10 | AAMVA 10 |

Parsed fields

| Field | AAMVA ID | Notes | |-------|----------|-------| | FirstName | DAC / DCT | Split from DCT on v03 | | MiddleName | DAD / DCT | | | LastName | DCS | | | LicenseId | DAQ | | | DateOfBirth | DBB | Raw MMDDYYYY string | | DocumentIssueDate | DBD | | | DocumentExpirationDate | DBA | | | Gender | DBC | Male, Female, or NotSpecified | | IsMale | DBC | Kept for backward compatibility | | AddressStreet | DAG | | | AddressStreet2 | DAH | | | AddressCity | DAI | | | AddressState | DAJ | | | AddressPostalCode | DAK | | | OrganDonor | DDK | | | Veteran | DDL | | | Under21Until | DDJ | |

See DriversLicense in the source for the full list of optional fields.

Privacy & security

This library parses sensitive personally identifiable information (PII) including names, addresses, dates of birth, and license numbers.

  • All parsing happens locally in your application — this library does not transmit data anywhere.
  • You are responsible for securely handling, storing, transmitting, and retaining any parsed license data in compliance with applicable laws and your own privacy policies.
  • Avoid logging raw barcode strings or parsed PII in production systems.

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.

License

MIT