← Back to Discover

light-ocr

Offline text-recognition library and command-line tool for Node.js and C++ that reads images and PDFs and returns each line with a confidence score and coordinates.

Local modelsCommand-line tools

What it does

light-ocr recognizes text in JPEG, PNG and PDF files, encoded bytes or raw pixel buffers directly on your own machine. Images, PDFs and results stay local. Each result gives lines in reading order with the recognized text, a confidence score and quadrilateral box coordinates, plus page metadata and timing. The Node.js package ships the PP-OCRv6 Small model, a PDF renderer and a Chinese fallback font in one npm install, with no postinstall step or first-run download. Prebuilt binaries cover eight builds across macOS, Linux and Windows, and Node.js 22 or newer is supported. C++ projects build the static library from source. A light-ocr command is included for recognizing text, detecting regions only, limiting work to a region of interest and processing PDF page ranges, with JSON, text or JSONL output. Auto mode tries Core ML on Apple Silicon Macs and WebGPU on the Linux x64 glibc and Windows x64 builds, then falls back to CPU. An optional tiled mode helps with small, dense text in large images, and an Agent Skill is provided for AI agents that can call local commands.

Capabilities

  • Runs offline, keeping images, PDFs and results on your machine
  • Reads JPEG, PNG, PDF, encoded bytes or raw pixel data
  • Returns text, confidence and quadrilateral boxes for every line
  • Command-line tool with JSON, text and JSONL output
  • Core ML and WebGPU acceleration with a CPU fallback
  • Optional tiled mode for small text in high-resolution images

When to use it

  • Adding local text recognition to a Node.js app, CLI or desktop program
  • Extracting text from PDFs and scans without sending files to a cloud service
  • Integrating OCR into a native C++ project
  • Checking multimodal model output against deterministic OCR