# JavaScript OCR libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [@mistralai/mistralai](#mistralai-mistralai) | 27.0M | 161 | Nov 2026 | Apache-2.0 |
| [tesseract.js](#tesseract-js) | 22.2M | 38.8K | Dec 2025 | Apache-2.0 |
| [@aws-sdk/client-textract](#aws-sdk-client-textract) | 8.6M | 3.7K | Nov 2026 | Apache-2.0 |
| [Google Cloud Vision](#google-cloud-vision) | 3.5M | 3.2K | Oct 2026 | Apache-2.0 |
| [@google-cloud/documentai](#google-cloud-documentai) | 2.5M | 3.2K | Oct 2026 | Apache-2.0 |
| [@azure-rest/ai-document-intelligence](#azure-document-intelligence) | 1.5M | 2.3K | May 2025 | MIT |
| [@llamaindex/llama-cloud](#llamaindex-llama-cloud) | 758.4K | 36 | Oct 2026 | MIT |
| [node-tesseract-ocr](#node-tesseract-ocr) | 208.0K | 320 | May 2021 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Tesseract.js](#tesseract-js) has the most monthly downloads among the local OCR libraries in this comparison, at 21.6M.

## Capabilities

| Library | Native PDF input | Structured field extraction | Word bounding boxes |
| --- | --- | --- | --- |
| [@mistralai/mistralai](#mistralai-mistralai) | Yes | Yes | No |
| [tesseract.js](#tesseract-js) | No | No | Yes |
| [@aws-sdk/client-textract](#aws-sdk-client-textract) | Yes | Yes | Yes |
| [Google Cloud Vision](#google-cloud-vision) | Yes | No | Yes |
| [@google-cloud/documentai](#google-cloud-documentai) | Yes | Yes | Yes |
| [@azure-rest/ai-document-intelligence](#azure-document-intelligence) | Yes | Yes | Yes |
| [@llamaindex/llama-cloud](#llamaindex-llama-cloud) | Yes | Yes | Yes |
| [node-tesseract-ocr](#node-tesseract-ocr) | No | No | Yes |

## Libraries

### @mistralai/mistralai

[GitHub](https://github.com/mistralai/client-ts) · [npm](https://www.npmjs.com/package/@mistralai/mistralai) · [Docs](https://github.com/mistralai/client-ts#readme)

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
- Capabilities: [From the @mistralai/mistralai docs](https://github.com/mistralai/client-ts#readme)

```sh
npm install @mistralai/mistralai
```

**getomni-ai/benchmark** (638 stars)

[getomni-ai/benchmark](https://github.com/getomni-ai/benchmark) 

```javascript
async ocr(imagePath: string) {
    try {
      const start = performance.now();

      const response = await this.client.ocr.process({
        model: 'mistral-ocr-latest',
        document: {
          imageUrl: imagePath,
        },
        includeImageBase64: true,
      });

      const text = response.pages.map((page) => page.markdown).join('\n');
      const end = performance.now();

      const imageBase64s = response.pages.flatMap((page) =>
        page.images.map((image) => image.imageBase64).filter((base64) => base64),
      );

      return {
        text,
        imageBase64s,
        usage: {
          duration: end - start,
          totalCost: COST_PER_IMAGE,
        },
      };
    } catch (error) {
      console.error('Mistral OCR Error:', error);
      throw error;
    }
  }
```

[src/models/mistral.ts](https://github.com/getomni-ai/benchmark/blob/cf84a584745297e97f53921e1b8896522fd3c75b/src/models/mistral.ts#L25-L56) · [More projects using @mistralai/mistralai →](https://dashboard.exa.ai/playground/search?q=%40mistralai/mistralai%20GitHub%20projects)

**Quickstart**

```javascript
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);

```

From [ocrrequest.ts](https://docs.mistral.ai/capabilities/document_ai/basic_ocr/)

### tesseract.js

[GitHub](https://github.com/naptha/tesseract.js) · [npm](https://www.npmjs.com/package/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
- Capabilities: [From the tesseract.js docs](https://github.com/naptha/tesseract.js)

**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.

**Watch out for**

- **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.

```sh
npm install tesseract.js
```

**alam00000/bentopdf** (16.4K stars)

[alam00000/bentopdf](https://github.com/alam00000/bentopdf) 

```typescript
function recognizeWithTimeout(
  worker: Tesseract.Worker,
  canvas: HTMLCanvasElement,
  timeoutMs: number
): Promise<Tesseract.RecognizeResult> {
  return new Promise((resolve, reject) => {
    const timer = setTimeout(() => {
      const error = new Error(
        trText('OCR recognize timed out after {{timeoutMs}}ms', { timeoutMs })
      );
      error.name = 'OcrTimeoutError';
      reject(error);
    }, timeoutMs);
    worker
      .recognize(canvas, {}, { text: true, hocr: true })
      .then((result) => {
        clearTimeout(timer);
        resolve(result);
      })
      .catch((err) => {
        clearTimeout(timer);
        reject(err);
      });
  });
}
```

[src/js/utils/ocr.ts](https://github.com/alam00000/bentopdf/blob/cc97429413ee13fa977d18627003b9b69e1787e6/src/js/utils/ocr.ts#L154-L178) · [More projects using tesseract.js →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20projects%20using%20tesseract.js%20for%20OCR%2C%20scanned%20documents%2C%20PDF%20text%20layers%2C%20document%20layout%20and%20text%20coordinates&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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();
})();

```

From [README.md](https://raw.githubusercontent.com/naptha/tesseract.js/master/README.md)

### @aws-sdk/client-textract

[GitHub](https://github.com/aws/aws-sdk-js-v3) · [npm](https://www.npmjs.com/package/@aws-sdk/client-textract) · [Docs](https://github.com/aws/aws-sdk-js-v3/tree/main/clients/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
- Capabilities: [From the @aws-sdk/client-textract docs](https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-textract)

```sh
npm install @aws-sdk/client-textract
```

**getomni-ai/benchmark** (638 stars)

[getomni-ai/benchmark](https://github.com/getomni-ai/benchmark) 

```javascript
async ocr(imagePath: string) {
    try {
      // Convert image URL to base64
      const response = await fetch(imagePath);
      const arrayBuffer = await response.arrayBuffer();
      const buffer = Buffer.from(arrayBuffer);

      const start = performance.now();
      const command = new AnalyzeDocumentCommand({
        Document: {
          Bytes: buffer,
        },
        FeatureTypes: ['LAYOUT'],
      });

      const result = await this.client.send(command);
      const end = performance.now();

      // Extract text from blocks
      const text =
        result.Blocks?.filter((block) => block.Text)
          .map((block) => block.Text)
          .join('\n') || '';

      return {
        text,
        usage: {
          duration: end - start,
          totalCost: COST_PER_PAGE, // the input is always 1 page.
        },
      };
    } catch (error) {
      console.error('AWS Textract Error:', error);
      throw error;
    }
  }
```

[src/models/awsTextract.ts](https://github.com/getomni-ai/benchmark/blob/cf84a584745297e97f53921e1b8896522fd3c75b/src/models/awsTextract.ts#L22-L57) · [More projects using @aws-sdk/client-textract →](https://dashboard.exa.ai/playground/search?q=%40aws-sdk/client-textract%20GitHub%20projects)

**Quickstart**

```javascript
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);

```

From [DetectDocumentTextCommand.d.ts](https://cdn.jsdelivr.net/npm/@aws-sdk/client-textract@3.1171.0/dist-types/commands/DetectDocumentTextCommand.d.ts)

### Google Cloud Vision

[GitHub](https://github.com/googleapis/google-cloud-node) · [npm](https://www.npmjs.com/package/@google-cloud/vision) · [Docs](https://github.com/googleapis/google-cloud-node/tree/main/packages/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
- Capabilities: [From the Google Cloud Vision docs](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-vision)

```sh
npm install @google-cloud/vision
```

**GoogleCloudPlatform/nodejs-docs-samples** (3.0K stars)

[GoogleCloudPlatform/nodejs-docs-samples](https://github.com/GoogleCloudPlatform/nodejs-docs-samples) 

```javascript
async function detectFulltext(fileName) {
  // [START vision_fulltext_detection]

  // Imports the Google Cloud client library
  const vision = require('@google-cloud/vision');

  // Creates a client
  const client = new vision.ImageAnnotatorClient();

  /**
   * TODO(developer): Uncomment the following line before running the sample.
   */
  // const fileName = 'Local image file, e.g. /path/to/image.png';

  // Read a local image as a text document
  const [result] = await client.documentTextDetection(fileName);
  const fullTextAnnotation = result.fullTextAnnotation;
  console.log(`Full text: ${fullTextAnnotation.text}`);
  fullTextAnnotation.pages.forEach(page => {
    page.blocks.forEach(block => {
      console.log(`Block confidence: ${block.confidence}`);
      block.paragraphs.forEach(paragraph => {
        console.log(`Paragraph confidence: ${paragraph.confidence}`);
        paragraph.words.forEach(word => {
          const wordText = word.symbols.map(s => s.text).join('');
          console.log(`Word text: ${wordText}`);
          console.log(`Word confidence: ${word.confidence}`);
          word.symbols.forEach(symbol => {
            console.log(`Symbol text: ${symbol.text}`);
            console.log(`Symbol confidence: ${symbol.confidence}`);
          });
        });
      });
    });
  });
  // [END vision_fulltext_detection]
}
```

[vision/detect.js](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/7d399e2b93deac11a75e781b0525580d8a7cceec/vision/detect.js#L626-L662) · [More projects using Google Cloud Vision →](https://dashboard.exa.ai/playground/search?q=%40google-cloud/vision%20GitHub%20projects)

**Quickstart**

```javascript
const { ImageAnnotatorClient } = require('@google-cloud/vision');
(async () => {
  const client = new ImageAnnotatorClient();
  const [result] = await client.textDetection('./image.png');
  console.log(result.textAnnotations?.[0]?.description ?? '');
})();

```

From [helpers.d.ts](https://cloud.google.com/vision/docs/ocr)

### @google-cloud/documentai

[GitHub](https://github.com/googleapis/google-cloud-node) · [npm](https://www.npmjs.com/package/@google-cloud/documentai) · [Docs](https://github.com/googleapis/google-cloud-node/tree/main/packages/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
- Capabilities: [From the @google-cloud/documentai docs](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-documentai)

```sh
npm install @google-cloud/documentai
```

**getomni-ai/benchmark** (638 stars)

[getomni-ai/benchmark](https://github.com/getomni-ai/benchmark) 

```javascript
async ocr(imagePath: string) {
    try {
      // Download the image
      const response = await fetch(imagePath);
      const arrayBuffer = await response.arrayBuffer();
      const imageContent = Buffer.from(arrayBuffer).toString('base64');

      // Determine MIME type from URL
      const mimeType = this.getMimeType(imagePath);

      const request = {
        name: this.processorPath,
        rawDocument: {
          content: imageContent,
          mimeType: mimeType,
        },
      };

      const start = performance.now();
      const [result] = await this.client.processDocument(request);
      const { document } = result;
      const end = performance.now();

      // Extract text from the document
      const text = document?.text || '';

      return {
        text,
        usage: {
          duration: end - start,
          totalCost: COST_PER_PAGE, // the input is always 1 page.
        },
      };
    } catch (error) {
      console.error('Google Document AI Error:', error);
      throw error;
    }
  }
```

[src/models/googleDocumentAI.ts](https://github.com/getomni-ai/benchmark/blob/cf84a584745297e97f53921e1b8896522fd3c75b/src/models/googleDocumentAI.ts#L34-L71) · [More projects using @google-cloud/documentai →](https://dashboard.exa.ai/playground/search?q=%40google-cloud/documentai%20GitHub%20projects)

**Quickstart**

```javascript
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);
})();

```

From [document_processor_service_client.d.ts](https://cdn.jsdelivr.net/npm/@google-cloud/documentai@10.2.0/build/src/v1/document_processor_service_client.d.ts)

### @azure-rest/ai-document-intelligence

[GitHub](https://github.com/Azure/azure-sdk-for-js) · [npm](https://www.npmjs.com/package/@azure-rest/ai-document-intelligence) · [Docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/documentintelligence/ai-document-intelligence-rest/README.md)

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
- Capabilities: [From the @azure-rest/ai-document-intelligence docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/documentintelligence/ai-document-intelligence-rest/README.md)

**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.

**Watch out for**

- **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.

```sh
npm install @azure-rest/ai-document-intelligence
```

**getomni-ai/benchmark** (638 stars)

[getomni-ai/benchmark](https://github.com/getomni-ai/benchmark) 

```typescript
async ocr(imagePath: string) {
    try {
      const start = performance.now();

      const initialResponse = await this.client
        .path('/documentModels/{modelId}:analyze', 'prebuilt-layout')
        .post({
          contentType: 'application/json',
          body: {
            urlSource: imagePath,
          },
          queryParameters: { outputContentFormat: 'markdown' },
        });

      if (isUnexpected(initialResponse)) {
        throw initialResponse.body.error;
      }

      const poller = getLongRunningPoller(this.client, initialResponse);
      const result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;
      const analyzeResult = result.analyzeResult;
      const text = analyzeResult?.content;

      const end = performance.now();

      return {
        text,
        usage: {
          duration: end - start,
          totalCost: COST_PER_PAGE, // the input is always 1 page.
        },
      };
    } catch (error) {
      console.error('Azure Document Intelligence Error:', error);
      throw error;
    }
  }
```

[src/models/azure.ts](https://github.com/getomni-ai/benchmark/blob/cf84a584745297e97f53921e1b8896522fd3c75b/src/models/azure.ts#L31-L67) · [More projects using @azure-rest/ai-document-intelligence →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20projects%20using%20%40azure-rest/ai-document-intelligence%20for%20OCR%2C%20scanned%20documents%2C%20PDF%20text%20layers%2C%20document%20layout%20and%20text%20coordinates&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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);

```

From [README.md](https://cdn.jsdelivr.net/npm/@azure-rest/ai-document-intelligence@1.1.0/README.md)

### @llamaindex/llama-cloud

[GitHub](https://github.com/run-llama/llama-parse-ts) · [npm](https://www.npmjs.com/package/@llamaindex/llama-cloud) · [Docs](https://github.com/run-llama/llama-parse-ts#readme)

Provides the official TypeScript library for the Llama Cloud API.

- Downloads / mo: 758.4K
- Stars: 36
- Last release: 2.19.0
- License: MIT
- Capabilities: [From the @llamaindex/llama-cloud docs](https://github.com/run-llama/llama-parse-ts#readme)

```sh
npm install @llamaindex/llama-cloud
```

**Quickstart**

```javascript
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);

```

From [parsing.d.ts](https://cdn.jsdelivr.net/npm/@llamaindex/llama-cloud@2.19.0/resources/parsing.d.ts) · [Find projects using @llamaindex/llama-cloud →](https://dashboard.exa.ai/playground/search?q=%40llamaindex/llama-cloud%20GitHub%20projects)

### node-tesseract-ocr

[GitHub](https://github.com/zapolnoch/node-tesseract-ocr) · [npm](https://www.npmjs.com/package/node-tesseract-ocr) · [Docs](https://github.com/zapolnoch/node-tesseract-ocr#readme)

Wraps the Tesseract OCR engine for Node.js.

- Downloads / mo: 208.0K
- Stars: 320
- Last release: 2.2.1
- License: MIT
- Capabilities: [From the node-tesseract-ocr docs](https://github.com/zapolnoch/node-tesseract-ocr#readme)

```sh
npm install node-tesseract-ocr
```

**Quickstart**

```javascript
const tesseract = require('node-tesseract-ocr');
tesseract.recognize('./image.png', { lang: 'eng' }).then(console.log).catch(console.error);

```

From [readme.md](https://cdn.jsdelivr.net/npm/node-tesseract-ocr@2.2.1/readme.md) · [Find projects using node-tesseract-ocr →](https://dashboard.exa.ai/playground/search?q=node-tesseract-ocr%20GitHub%20projects)

## FAQ

### Which JavaScript OCR library should I use?

[Tesseract.js](#tesseract-js) suits apps that run OCR locally in the browser or Node.js. [Azure Document Intelligence](#azure-document-intelligence), [AWS Textract SDK](#aws-sdk-client-textract), and [Google Document AI](#google-cloud-documentai) suit apps that need forms, tables, and layout from PDFs.

### What is Azure Document Intelligence?

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

### What is LlamaParse?

LlamaParse is the document parsing service in Llama Cloud. The [LlamaCloud SDK](#llamaindex-llama-cloud) starts a parsing job and returns its results with bounding boxes.

### What is AWS Textract?

AWS Textract is Amazon's cloud service for detecting text and analyzing forms, tables, and layout. The [AWS Textract SDK](#aws-sdk-client-textract) returns each block with a bounding box and polygon.

### What is Mistral OCR?

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

### Can Tesseract.js read PDFs?

[Tesseract.js](#tesseract-js) reads images rather than PDF files. A PDF page needs conversion to an image before recognition.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript OCR libraries Tesseract.js Scribe.js Guten OCR Azure Document Intelligence code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
