Decode US Driver License PDF417 Barcodes with Node.js

Call a deterministic PDF417 and AAMVA API from Node.js, return structured identity fields, and reject unreadable barcodes without AI guessing.

Why US Driver License PDF417 Decoding Needs a Dedicated Pipeline

The barcode on the back of a US driver license is not ordinary printed text. PDF417 uses stacked rows, error correction, and a structured AAMVA payload. Glare, blur, perspective, small barcodes, and partial cropping can prevent a reliable decode. General OCR and generative vision models may produce plausible-looking identity fields, but they cannot prove those values came from a valid barcode payload.

A Deterministic PDF417 API for Node.js

Send a JPG, PNG, or WebP image to the US driver license PDF417 API. StructOCR locates and decodes the barcode, validates the result, parses AAMVA elements, and returns normalized JSON. Try the workflow first in the free PDF417 scanner.

Production Use Cases

  • US Customer Onboarding: Pre-fill identity and address fields from an AAMVA-compliant license-back barcode.
  • Rental and Fleet Intake: Capture license number, class, restrictions, endorsements, and expiration date.
  • Quality-Control Queues: Route 422 responses to a retake flow instead of accepting guessed identity data.
Need more testing? Create a free account to get 200 free credits (equals 100 Driver License scans).

Implementation: Node.js REST Request

Read the license-back image, Base64 encode it, send it with the x-api-key header, and treat HTTP 422 as a request for a clearer image.

Prerequisite: Node.js 18+ using the built-in Fetch API

JAVASCRIPT EXAMPLE
const fs = require('node:fs');

const image = fs.readFileSync('license-back.jpg').toString('base64');
const response = await fetch('https://api.structocr.com/v1/driver-license-pdf417', {
  method: 'POST',
  headers: {
    'content-type': 'application/json',
    'x-api-key': process.env.STRUCTOCR_API_KEY,
  },
  body: JSON.stringify({ img: image }),
  signal: AbortSignal.timeout(30000),
});

const result = await response.json();
if (response.status === 422) {
  console.log('Retake the barcode image:', result.error);
} else if (!response.ok) {
  throw new Error(result.message || result.error);
} else {
  console.log('License:', result.data.document_number);
  console.log('Name:', result.data.given_names, result.data.surname);
  console.log('DOB:', result.data.date_of_birth);
  console.log('AAMVA version:', result.data.aamva_version);
}

Technical Specs

  • •Endpoint: POST https://api.structocr.com/v1/driver-license-pdf417
  • •Authentication: x-api-key request header
  • •Inputs: JPG, PNG, or WebP; Base64 JSON or multipart upload
  • •Maximum file size: 4.5MB
  • •Price: 2 credits for a successful decode; processing failures are refunded
  • •Output: Structured AAMVA JSON; raw barcode payload is not returned

Key Features

  • •No AI guessing: Identity fields come from a decoded PDF417 payload and AAMVA parser.
  • •Explicit retake flow: Handle PDF417_NOT_DECODED as a 422 response and ask for a clear, glare-free image.
  • •AAMVA validation: AAMVA_NOT_VALID distinguishes a readable non-license barcode from a usable driver-license record.
  • •Normalized dates: Birth, issue, and expiration dates use YYYY-MM-DD when available.

Sample AAMVA JSON Output

The example uses fictional values. Optional AAMVA elements return null when absent.

{
  "success": true,
  "data": {
    "type": "drivers_license",
    "source": "pdf417",
    "country_code": "USA",
    "region": "CA",
    "document_number": "SAMPLE1234",
    "surname": "SAMPLE",
    "given_names": "ALEX MORGAN",
    "first_name": "ALEX",
    "middle_name": "MORGAN",
    "sex": "F",
    "date_of_birth": "1990-01-15",
    "date_of_issue": "2025-01-15",
    "date_of_expiry": "2030-01-15",
    "address": "100 EXAMPLE AVE",
    "city": "SAMPLE CITY",
    "postal_code": "90001",
    "vehicle_class": "C",
    "restrictions": "NONE",
    "endorsements": "NONE",
    "document_discriminator": "SAMPLE-DISCRIMINATOR",
    "issuer_identification_number": "636000",
    "aamva_version": 10,
    "jurisdiction_version": 0
  }
}

Frequently Asked Questions

Can Node.js decode a PDF417 barcode without a local barcode library?

Yes. Your application only needs to send the image to the REST endpoint and parse JSON. PDF417 decoding and AAMVA parsing run in the StructOCR service.

What should my application do with PDF417_NOT_DECODED?

Treat HTTP 422 as a recoverable capture problem. Ask the user to retake the back of the license with the full barcode visible, sharp, and free from glare. Processing failures are refunded.

Is this the same as front-side driver license OCR?

No. This endpoint is dedicated to PDF417 barcodes on the back of US driver licenses and State IDs. Use the Driver License OCR API for visible printed fields and international license formats.

You May Also Like

Related tutorials, platform guides, and comparisons

Country Tutorial

Canada Driver License OCR with Node.js SDK

Extract structured fields from a Canada provincial driver licence with the StructOCR Node.js SDK and TypeScript + Express.

Node.js · Driver License
Country Tutorial

US Driver License OCR with Node.js SDK

Extract structured fields from a United States state-issued driver license with the StructOCR Node.js SDK and TypeScript + Express.

Node.js · Driver License
Country Tutorial

UK Driver License OCR with Node.js SDK

Extract structured fields from a United Kingdom photocard driving licence with the StructOCR Node.js SDK and TypeScript + Express.

Node.js · Driver License
Country Tutorial

Philippines Driver License OCR with Node.js SDK

Extract structured fields from a Philippines LTO driver's license with the StructOCR Node.js SDK and TypeScript + Express.

Node.js · Driver License
Tutorial

Node.js Driver License Verification API

Stop manual driver license checks. Our Node.js API delivers verified data in JSON within <4s, secured by AES-256 encryption and SOC2 compliance. Upload an image for a free test!

Node.js · Driver License
Country Tutorial

Brazil Driver License OCR with Node.js SDK

Extract structured fields from a Brazil Carteira Nacional de Habilitação (CNH) with the StructOCR Node.js SDK and TypeScript + Express.

Node.js · Driver License
Country Tutorial

Australia Driver License OCR with Node.js SDK

Extract structured fields from a Australia state or territory driver licence with the StructOCR Node.js SDK and TypeScript + Express.

Node.js · Driver License
Country Tutorial

Canada Driver License OCR with Python SDK

Extract structured fields from a Canada provincial driver licence with the StructOCR Python SDK and FastAPI.

Python · Driver License
Country Tutorial

Philippines Driver License OCR with Python SDK

Extract structured fields from a Philippines LTO driver's license with the StructOCR Python SDK and FastAPI.

Python · Driver License
Tutorial

Node.js Vehicle Registration OCR API

Node.js Vehicle Registration OCR API tutorial. Upload an image for a free test! Accurately extract standardized fields like VIN, make, and model, along with dynamically localized data for global documents.

Node.js · Vehicle Reg.

Technical Comparisons & Integrations

Explore platform integrations and competitive analysis

From tutorial to production in 5 minutes.

You've seen the code. Now get your API key, grab your 200 free credits, and see it work with your own images. No credit card required.

Instant Access Cancel Anytime No Credit Card