Tesseract.js is a JavaScript library that provides Optical Character Recognition (OCR) capabilities directly in both browser and Node.js environments. It functions by wrapping a WebAssembly port of the popular Tesseract OCR engine, enabling it to extract text from images in nearly any language. The current stable version is `7.0.0`, which brings significant recognition speed improvements (15-35% faster) through optimized WebAssembly and hardware capabilities. The project generally follows a regular release cadence, with major versions often introducing performance enhancements and minor versions addressing bugs or adding small features. A key differentiator is its ability to run Tesseract purely in JavaScript, without requiring native system dependencies. However, it explicitly states that it does not provide direct PDF file support or modify the core Tesseract recognition model to improve accuracy.
npm install tesseract.jsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a Tesseract.js worker, load the English language model, recognize text from a remote image, log the output, and properly terminate the worker.
Upgrade your Node.js environment to v16 or newer to use Tesseract.js v7.
To enable specific output formats (e.g., `blocks`, `words`), you must explicitly configure them when creating the worker or using `worker.setParameters`.
For parallel processing of multiple images, use `createScheduler` to manage jobs across multiple workers, or ensure each `worker.recognize` call completes before initiating another on the same worker.
For PDF processing, pre-convert PDF pages into image formats (e.g., PNG, JPEG) before passing them to Tesseract.js. For advanced model tuning or features beyond core Tesseract, consider other OCR solutions or pre-process images for better Tesseract results.
Upgrade to Tesseract.js v7 to benefit from the performance enhancements and optimize OCR processing times.
Upgrade your Node.js environment to v16 or newer. If you must use Node.js v14, you would need to use an older Tesseract.js version (e.g., v5) or provide a global `fetch` polyfill.
Verify the language code is correct (e.g., 'eng' for English). Ensure there is network access to the Tesseract.js CDN. If loading local data, confirm the `langPath` option is correctly set when calling `createWorker` and that the language files exist at that location.
Use `await` for each `worker.recognize` call or, for parallel image processing, utilize `Tesseract.createScheduler()` to manage jobs across multiple workers efficiently.
Switch to ES Module `import` syntax: `import { createWorker } from 'tesseract.js';`. Ensure your environment supports ES Modules.No dependency data recorded yet.