JavaScript OCR libraries

Updated Nov 2026

JavaScript OCR (optical character recognition) libraries extract text from images and scanned documents in Node.js and the browser. A library either runs an OCR engine on the device or sends each page to a cloud document service. These libraries turn scanned forms, receipts, and screenshots into text that search systems and AI agents can read.

Popularity

Tesseract.js has the most monthly downloads among the local OCR libraries in this comparison, at 21.6M.

LibraryMonthly downloadsStarsLast releaseLicense
@mistralai/mistralai
27.0M
161Nov 2026Apache-2.0
tesseract.js
22.2M
38.8KDec 2025Apache-2.0
@aws-sdk/client-textract
8.6M
3.7KNov 2026Apache-2.0
Google Cloud Vision
3.5M
3.2KOct 2026Apache-2.0
@google-cloud/documentai
2.5M
3.2KOct 2026Apache-2.0
@azure-rest/ai-document-intelligence
1.5M
2.3KMay 2025MIT
@llamaindex/llama-cloud
758.4K
36Oct 2026MIT
node-tesseract-ocr
208.0K
320May 2021MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryNative PDF inputStructured field extractionWord bounding boxes
@mistralai/mistralaiBuilt-inBuilt-inUnsupported
tesseract.jsUnsupportedUnsupportedBuilt-in
@aws-sdk/client-textractBuilt-inBuilt-inBuilt-in
Google Cloud VisionBuilt-inUnsupportedBuilt-in
@google-cloud/documentaiBuilt-inBuilt-inBuilt-in
@azure-rest/ai-document-intelligenceBuilt-inBuilt-inBuilt-in
@llamaindex/llama-cloudBuilt-inBuilt-inBuilt-in
node-tesseract-ocrUnsupportedUnsupportedBuilt-in
Built-inNot supported

Libraries and code examples

@mistralai/mistralai

Provides the TypeScript client library for the Mistral AI API.

Downloads / mo
27.0M
Stars
161
Last release
3.5.0
License
Apache-2.0

Quickstart

From ocrrequest.ts
$ npm install @mistralai/mistralai
import { Mistral } from '@mistralai/mistralai';
const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
const result = await client.ocr.process({ model: 'mistral-ocr-latest', document: { type: 'document_url', documentUrl: 'https://arxiv.org/pdf/2201.04234' } });
console.log(result.pages[0]?.markdown);

@mistralai/mistralai examples

From open-source projects on GitHub

tesseract.js

Runs the Tesseract OCR engine in browsers and Node.js through WebAssembly.

Downloads / mo
22.2M
Stars
38.8K
Last release
7.0.0
License
Apache-2.0

Strengths

  • Reuses initialized OCR workers. Reuse a worker for multiple images before terminating it.
  • Restricts recognized characters. Set tessedit_char_whitelist when only specified characters are valid.

Limitations

  • PDF input needs image rendering. Render PDF pages as images before passing them to Tesseract.js.
  • Structured output needs explicit enabling. Enable blocks or hocr when downstream code needs document layout.

Quickstart

From README.md
$ npm install tesseract.js
import { createWorker } from 'tesseract.js';

(async () => {
  const worker = await createWorker('eng');
  const ret = await worker.recognize('https://tesseract.projectnaptha.com/img/eng_bw.png');
  console.log(ret.data.text);
  await worker.terminate();
})();

tesseract.js examples

From open-source projects on GitHub

@aws-sdk/client-textract

Provides the AWS SDK client for Amazon Textract in Node.js, browsers, and React Native.

Downloads / mo
8.6M
Stars
3.7K
Last release
3.1171.0
License
Apache-2.0
$ npm install @aws-sdk/client-textract
import { TextractClient, DetectDocumentTextCommand } from '@aws-sdk/client-textract';
import { readFile } from 'node:fs/promises';
const client = new TextractClient({});
const result = await client.send(new DetectDocumentTextCommand({ Document: { Bytes: await readFile('./image.png') } }));
console.log(result.Blocks);

@aws-sdk/client-textract examples

From open-source projects on GitHub

Google Cloud Vision

Provides the Google Cloud Vision API client for Node.js.

Downloads / mo
3.5M
Stars
3.2K
Last release
6.2.0
License
Apache-2.0

Quickstart

From helpers.d.ts
$ npm install @google-cloud/vision
const { ImageAnnotatorClient } = require('@google-cloud/vision');
(async () => {
  const client = new ImageAnnotatorClient();
  const [result] = await client.textDetection('./image.png');
  console.log(result.textAnnotations?.[0]?.description ?? '');
})();

Google Cloud Vision examples

From open-source projects on GitHub

@google-cloud/documentai

Provides the Document AI client for Node.js.

Downloads / mo
2.5M
Stars
3.2K
Last release
10.2.0
License
Apache-2.0
$ npm install @google-cloud/documentai
const { DocumentProcessorServiceClient } = require('@google-cloud/documentai');
const { readFile } = require('node:fs/promises');
(async () => {
  const client = new DocumentProcessorServiceClient();
  const [result] = await client.processDocument({ name: process.env.DOCUMENT_AI_PROCESSOR, rawDocument: { content: (await readFile('./document.pdf')).toString('base64'), mimeType: 'application/pdf' } });
  console.log(result.document?.text);
})();

@google-cloud/documentai examples

From open-source projects on GitHub

@azure-rest/ai-document-intelligence

Calls Document Intelligence to extract document content, layout, and structured data.

Downloads / mo
1.5M
Stars
2.3K
Last release
1.1.0
License
MIT

Strengths

  • Extracts layout alongside text. Use prebuilt-layout to retrieve text and document structure.
  • Returns formatted document content. Request Markdown output when downstream code needs document formatting.

Limitations

  • Requires an OCR service. Connect to a Document Intelligence endpoint rather than an embedded OCR engine.
  • Searchable PDF requires prebuilt-read. Use PDF input with prebuilt-read for searchable PDF output.

Quickstart

From README.md
$ npm install @azure-rest/ai-document-intelligence
import DocumentIntelligence, { isUnexpected, getLongRunningPoller, type AnalyzeOperationOutput } from '@azure-rest/ai-document-intelligence';
import { readFile } from 'node:fs/promises';
const client = DocumentIntelligence(process.env.DOCUMENT_INTELLIGENCE_ENDPOINT!, { key: process.env.DOCUMENT_INTELLIGENCE_API_KEY! });
const response = await client.path('/documentModels/{modelId}:analyze', 'prebuilt-layout').post({ contentType: 'application/json', body: { base64Source: await readFile('./document.pdf', { encoding: 'base64' }) } });
if (isUnexpected(response)) throw response.body.error;
const result = (await getLongRunningPoller(client, response).pollUntilDone()).body as AnalyzeOperationOutput;
console.log(result.analyzeResult?.content);

@azure-rest/ai-document-intelligence examples

From open-source projects on GitHub

@llamaindex/llama-cloud

Provides the official TypeScript library for the Llama Cloud API.

Downloads / mo
758.4K
Stars
36
Last release
2.19.0
License
MIT

Quickstart

From parsing.d.ts
$ npm install @llamaindex/llama-cloud
import LlamaCloud from '@llamaindex/llama-cloud';
const client = new LlamaCloud();
const result = await client.parsing.parse({ tier: 'cost_effective', version: 'latest', source_url: 'https://arxiv.org/pdf/2201.04234', expand: ['markdown'] });
console.log(result.markdown);

node-tesseract-ocr

Wraps the Tesseract OCR engine for Node.js.

Downloads / mo
208.0K
Stars
320
Last release
2.2.1
License
MIT

Quickstart

From readme.md
$ npm install node-tesseract-ocr
const tesseract = require('node-tesseract-ocr');
tesseract.recognize('./image.png', { lang: 'eng' }).then(console.log).catch(console.error);

FAQ

Tesseract.js suits apps that run OCR locally in the browser or Node.js. Azure Document Intelligence, AWS Textract SDK, and Google Document AI suit apps that need forms, tables, and layout from PDFs.

Azure Document Intelligence is Microsoft's cloud service for extracting text, layout, and structured data from documents. The Azure Document Intelligence REST client analyzes a document from a URL or encoded file data and polls the long-running result.

LlamaParse is the document parsing service in Llama Cloud. The LlamaCloud SDK starts a parsing job and returns its results with bounding boxes.

AWS Textract is Amazon's cloud service for detecting text and analyzing forms, tables, and layout. The AWS Textract SDK returns each block with a bounding box and polygon.

Mistral OCR is the document OCR model in the Mistral AI API. The Mistral AI SDK accepts PDF input and can return schema-directed annotations of a document.

Tesseract.js reads images rather than PDF files. A PDF page needs conversion to an image before recognition.

For coding agents

Found your OCR library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official