Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 17, 2026·3 min de lecture

Tesseract.js — Pure JavaScript OCR for 100+ Languages

Run optical character recognition entirely in the browser or Node.js with no native dependencies, supporting over 100 languages via a WebAssembly port of the Tesseract engine.

Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 17/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
Script
Installation
Stage only
Confiance
Confiance : Established
Point d'entrée
Tesseract.js
Commande de staging sûr
npx -y tokrepo@latest install d5db39a9-8175-11f1-9bc6-00163e2b0d79 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

Introduction

Tesseract.js brings the Tesseract OCR engine to JavaScript through WebAssembly, enabling text extraction from images directly in browsers and Node.js environments. It eliminates the need for server-side OCR services or native binary installations, making document processing accessible to any JavaScript application.

What Tesseract.js Does

  • Extracts printed text from images in over 100 languages including CJK scripts
  • Runs entirely client-side in the browser via WebAssembly with no server round-trips
  • Provides word-level bounding boxes, confidence scores, and paragraph segmentation
  • Supports multiple workers for parallel OCR processing of batch images
  • Detects page orientation and script direction automatically

Architecture Overview

Tesseract.js wraps the C++ Tesseract engine compiled to WebAssembly via Emscripten. A scheduler distributes recognition tasks across web workers (browser) or worker threads (Node.js), each loading trained language data files on demand. The library exposes a Promise-based API that handles worker lifecycle, memory management, and data transfer transparently.

Self-Hosting & Configuration

  • Install via npm or load from a CDN script tag for browser use
  • Language data files are fetched from a CDN by default; set workerPath and langPath to serve them from your own origin
  • Configure tessedit_pageseg_mode to optimize for single lines, blocks, or full pages
  • Use worker.setParameters to whitelist character sets or switch OCR engine modes (legacy vs LSTM)
  • Pre-load language data with worker.loadLanguage to avoid latency at recognition time

Key Features

  • Zero native dependencies: pure JS and WASM, works in any modern browser or Node.js
  • Scheduler API for parallel processing across multiple workers
  • Incremental progress callbacks for real-time UI feedback during recognition
  • Supports combined language models (e.g., eng+fra) for multilingual documents
  • Compatible with image inputs from Canvas, File, Buffer, URL, or base64

Comparison with Similar Tools

  • Google Cloud Vision — cloud-hosted with higher accuracy on complex layouts, but requires API keys and per-request billing
  • Paddle OCR — Python-based with strong CJK accuracy; heavier runtime, not browser-native
  • EasyOCR — Python library with GPU support; better for server pipelines, not for client-side use
  • Amazon Textract — managed service with table and form extraction; vendor lock-in and cost at scale

FAQ

Q: How accurate is Tesseract.js compared to cloud OCR services? A: For clean printed text, accuracy is comparable. For complex layouts, handwriting, or low-quality scans, cloud services with custom models tend to perform better.

Q: Can it run in a web browser without a server? A: Yes. The entire engine runs client-side via WebAssembly. Language data is fetched once and can be cached.

Q: Does it support PDF input? A: Not directly. Convert PDF pages to images first using a library like pdf.js, then pass the images to Tesseract.js.

Q: How large are the language data files? A: The English trained data file is roughly 4 MB (gzipped). CJK languages are larger, around 10-20 MB each.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires