---
title: "How Tesseract OCR Works in the Browser and on Your Device"
description: "How Tesseract OCR turns images into text, how to run it in the browser or on your own computer, with JavaScript, TypeScript, Node, PHP code and real fixes."
url: "https://arbabnaseer.com/articles/how-tesseract-ocr-works/"
lang: "en"
author: "Arbab Naseer"
datePublished: "2026-10-22T00:00:00+05:00"
dateModified: "2026-10-22T00:00:00+05:00"
tags: "Tesseract, OCR, JavaScript, TypeScript, WebAssembly, PHP"
---

# How Tesseract OCR Works in the Browser and on Your Device

> How Tesseract OCR turns images into text, how to run it in the browser or on your own computer, with JavaScript, TypeScript, Node, PHP code and real fixes.

Arbab Naseer · 2026-10-22 · https://arbabnaseer.com/articles/how-tesseract-ocr-works/

**Short answer:** Tesseract is a free, open source OCR engine. It cleans up the image, finds the text lines, and reads each line with an LSTM neural network trained for one language. You can run it on your own computer (`tesseract image.png stdout`) or inside a web page with Tesseract.js, which compiles the engine to WebAssembly so the image never leaves the device.

I built [QuickImageToText](https://arbabnaseer.com/projects/quick-image-to-text-ocr-tool/), a free [image to text tool](https://quickimagetotext.com), on top of Tesseract.js. This guide explains how the engine works, how to use it locally and from code (JavaScript, TypeScript, Node.js, PHP and Python), and the problems I ran into in production with the fixes that worked.

## What is Tesseract OCR?

OCR (optical character recognition) is software that looks at an image and outputs the text it sees.

[Tesseract](https://github.com/tesseract-ocr/tesseract) started at Hewlett-Packard in the 1980s and 1990s, was open sourced in 2005, was developed by Google for many years and is now maintained by its community on GitHub. It is released under the Apache 2.0 licence, so you can use it in personal and commercial projects for free.

| Fact | Detail |
|---|---|
| Licence | Apache 2.0 (free for commercial use) |
| Written in | C++ |
| Recognition | LSTM neural network since version 4, plus the older "legacy" engine |
| Languages | More than 100 trained languages and scripts |
| Runs on | Windows, macOS, Linux, and in the browser through WebAssembly (Tesseract.js) |
| Input | PNG, JPG, TIFF, BMP, GIF, WebP and more (through Leptonica) |
| Output | Plain text, hOCR, TSV, ALTO XML, searchable PDF |

## How Tesseract reads text, step by step

Tesseract does not look at a picture the way you do. It runs the image through five stages and returns text with a confidence score.

### 1. Preprocessing (binarization)

Tesseract converts the image to black and white with Otsu thresholding. Each pixel becomes "ink" or "paper". This is why shadows, coloured backgrounds and low contrast hurt results: when the split goes wrong, letters break apart or merge.

### 2. Layout analysis (page segmentation)

Next it finds where the text is: columns, paragraphs, text blocks, and images to ignore. You can tell Tesseract what to expect with the page segmentation mode (PSM), for example "one block of text" or "one single line". The wrong PSM is a very common reason for bad output, so it has [its own section below](#page-segmentation-modes-psm-explained).

### 3. Line and word finding

Inside each block it finds the baseline of every text line, even when the line is slightly curved or tilted, and splits lines into words.

### 4. Recognition with an LSTM neural network

Since Tesseract 4, every text line goes through an LSTM (long short-term memory) network. Instead of recognising one isolated letter at a time, it reads the whole line as a sequence, left to right (or right to left for Arabic and Urdu), so it can use the neighbouring characters as context. That is the main reason modern Tesseract is far better than older OCR.

What the network knows lives in one `.traineddata` file per language: `eng.traineddata`, `fra.traineddata`, `jpn.traineddata` and so on. No traineddata, no recognition. The model file is the language support.

### 5. Language model and output

Word lists and character statistics from the traineddata help choose between similar shapes, like `rn` and `m`, or `0` and `O`. The result is text plus a confidence score from 0 to 100 for the page, each line and each word. A low score usually means the image is too blurry or the wrong language was chosen.

### OSD: orientation and script detection

Tesseract also ships a small special model called `osd`. It does not read text. It answers two questions: is the image rotated by 90, 180 or 270 degrees, and which writing system is it (Latin, Cyrillic, Arabic, Han, Devanagari)? QuickImageToText uses it for its Auto language mode.

## Tesseract vs Tesseract.js: device vs browser

There are two common ways to run Tesseract.

| | Tesseract (native) | Tesseract.js |
|---|---|---|
| What it is | The original C++ program | Tesseract compiled to WebAssembly, with a JavaScript API |
| Where it runs | Your computer or server (CLI or library) | Any modern browser, and Node.js |
| Install | `brew`, `apt` or the Windows installer | `npm install tesseract.js` or a `<script>` tag |
| Speed | Fastest | A bit slower, fine for normal images |
| Privacy | Files stay on your machine | Files stay in the visitor's browser |
| Works offline | Yes | Yes, once the engine and models are cached, if the app is built for it |
| Best for | Batch jobs, scripts, servers | Websites, web apps, browser extensions |

### How Tesseract.js runs in a browser

1. The C++ engine is compiled to a `.wasm` file with Emscripten. Browsers run WebAssembly at close to native speed. There are SIMD and non SIMD builds, and [Tesseract.js](https://github.com/naptha/tesseract.js) picks the one your browser supports.
2. OCR runs in a Web Worker, a background thread, so the page does not freeze while it works.
3. The traineddata file for the chosen language is downloaded (usually gzipped) and stored in the browser's IndexedDB, so the next run does not download it again.
4. Your image (a `File`, `Blob`, `<canvas>`, `<img>` or URL) is passed to the worker, recognised, and the text comes back to the page.

The image never has to leave the device. That is the main reason I chose it for QuickImageToText: no upload, no storage, and no server cost per image.

## How QuickImageToText uses Tesseract

QuickImageToText is built with plain PHP, vanilla JavaScript and Tesseract.js 5.1.1. All OCR runs in the browser. PHP only renders the pages and the language versions. There is no upload endpoint, so files are never sent to my server.

What it supports today:

- 19 OCR languages: English, Spanish, French, German, Italian, Portuguese, Russian, Ukrainian, Turkish, Arabic, Chinese (Simplified and Traditional), Japanese, Korean, Urdu, Persian, Hindi, Bengali and Thai.
- An Auto mode that detects the writing system, or a manual pick of up to 3 languages for mixed text, for example French and English.
- Images up to 10 MB: JPG, PNG, GIF, BMP, WebP, TIFF and iPhone [HEIC/HEIF](https://quickimagetotext.com/heic-to-text).
- [Batch OCR](https://quickimagetotext.com/multi-image-ocr) of up to 20 images at once.
- [PDF to text](https://quickimagetotext.com/pdf-to-text) up to 50 MB. The existing text layer is read directly, and up to 20 scanned pages per run go through OCR.
- A confidence score on every result, with a tip to retake the photo when it is low.

### What happens when you drop an image

1. The server has already sent the page with its config: size limits, languages and model paths.
2. When you choose, paste or drop a file, a preprocessing worker starts. It uses OffscreenCanvas to convert to grayscale, fix contrast, rotate, deskew and upscale, and it downloads, unzips and caches the language models.
3. An OSD worker detects the writing system and any quarter turn.
4. A single Tesseract.js worker reads the cleaned image. Jobs queue on it instead of creating a new worker each time.
5. The text, confidence score and word count appear in the result box. Nothing was uploaded at any step.

The design choices that made the biggest difference:

- **Self hosted engine and models.** Tesseract.js, its worker, the WebAssembly core and every traineddata file are served from my own domain in versioned folders (`/assets/tesseract/5.1.1/`, `/tessdata/4.1.0/`). No CDN is needed at OCR time, files are cached for a year, and a model change means a new folder, never an overwritten file.
- **The right model per script.** Small, fast models from [`tessdata_fast`](https://github.com/tesseract-ocr/tessdata_fast) for Latin and Cyrillic. The larger, more accurate [`tessdata_best`](https://github.com/tesseract-ocr/tessdata_best) models for Arabic, Urdu, Persian, Hindi, Bengali, Chinese, Japanese, Korean and Thai, where the fast ones made too many mistakes.
- **Lazy loading.** Nothing OCR related downloads when the page opens. Warm up starts when a file is chosen, so visitors who only read the page pay nothing.
- **No heavy work on the main thread.** Image cleanup and model handling run in a Web Worker, so scrolling and typing stay smooth during OCR.
- **One recognition worker, reused.** Creating a Tesseract worker is expensive. I create one, queue jobs on it and only switch its languages when needed.
- **One source of truth for numbers.** Limits like 10 MB or 20 images live in one PHP config file. PHP prints them into the page and the JavaScript reads the same values, so the text on the page and the real behaviour cannot disagree.

## Use Tesseract on your computer (free, local)

You do not need a website to use Tesseract. Installed locally it is free, private and works without internet.

### Install

On macOS with Homebrew:

```bash
brew install tesseract          # engine + English
brew install tesseract-lang     # all other languages (optional)
```

On Ubuntu or Debian:

```bash
sudo apt update
sudo apt install tesseract-ocr                  # engine + English
sudo apt install tesseract-ocr-fra tesseract-ocr-ara tesseract-ocr-jpn   # extra languages
```

On Windows, download the installer from the [UB Mannheim build](https://github.com/UB-Mannheim/tesseract/wiki), which the [official installation guide](https://tesseract-ocr.github.io/tessdoc/Installation.html) links to. Tick the extra languages you need during setup, then add the install folder (for example `C:\Program Files\Tesseract-OCR`) to your `PATH`.

Check that it works:

```bash
tesseract --version
tesseract --list-langs
```

### Extract text from an image on the command line

```bash
# print the text to the terminal
tesseract receipt.jpg stdout

# save it to output.txt
tesseract receipt.jpg output

# French and English text, one uniform block
tesseract page.png stdout -l fra+eng --psm 6

# searchable PDF from a scanned image
tesseract scan.png scan pdf

# word level data with confidence (TSV)
tesseract photo.jpg stdout tsv
```

### Batch a whole folder

```bash
# macOS / Linux
for f in *.png; do tesseract "$f" "${f%.*}" -l eng; done
```

```powershell
# Windows PowerShell
Get-ChildItem *.png | ForEach-Object { tesseract $_.FullName $_.BaseName -l eng }
```

## Extract text from an image with JavaScript

The code in this guide uses Tesseract.js 5.1.1, the version QuickImageToText runs. Newer major versions exist, so check the [API docs](https://github.com/naptha/tesseract.js/blob/master/docs/api.md) if you install the latest one.

This is the simplest way to add OCR to a website. Save it as an HTML file and open it from a local web server (for example `npx serve` or `php -S localhost:8000`):

```html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Image to text demo</title>
  <script src="https://cdn.jsdelivr.net/npm/tesseract.js@5.1.1/dist/tesseract.min.js"></script>
</head>
<body>
  <input type="file" id="file" accept="image/*">
  <p id="status"></p>
  <pre id="output"></pre>

  <script>
    const status = document.getElementById('status');
    const output = document.getElementById('output');

    document.getElementById('file').addEventListener('change', async (event) => {
      const file = event.target.files[0];
      if (!file) return;

      // v5: createWorker(languages, oem, options). OEM 1 = LSTM only.
      const worker = await Tesseract.createWorker('eng', 1, {
        logger: (m) => {
          if (m.status === 'recognizing text') {
            status.textContent = `Reading... ${Math.round(m.progress * 100)}%`;
          }
        },
      });

      const { data } = await worker.recognize(file);
      output.textContent = data.text;
      status.textContent = `Done. Confidence: ${Math.round(data.confidence)}%`;

      await worker.terminate();
    });
  </script>
</body>
</html>
```

### Self host instead of using a CDN

For a real site, serve the files yourself. You get better privacy, caching and reliability:

```js
const worker = await Tesseract.createWorker('eng', 1, {
  workerPath: '/vendor/tesseract/worker.min.js',
  corePath: '/vendor/tesseract/core/', // folder with the .wasm(.js) builds
  langPath: '/tessdata/4.1.0',         // folder with eng.traineddata.gz and the others
});
```

### Reuse one worker for many images

```js
const worker = await Tesseract.createWorker('eng', 1);

for (const file of files) {
  const { data } = await worker.recognize(file);
  console.log(file.name, data.text);
}

// switch language without creating a new worker
await worker.reinitialize(['fra', 'eng']);

await worker.terminate();
```

### Set the page segmentation mode

```js
await worker.setParameters({
  tessedit_pageseg_mode: Tesseract.PSM.SINGLE_LINE, // e.g. a code or a serial number
  tessedit_char_whitelist: '0123456789ABCDEF',       // optional: only these characters
});
```

### Read text from a pasted screenshot

```js
document.addEventListener('paste', async (event) => {
  const item = [...event.clipboardData.items].find((i) => i.type.startsWith('image/'));
  if (!item) return;
  const { data } = await worker.recognize(item.getAsFile());
  console.log(data.text);
});
```

## Use Tesseract.js with TypeScript

Tesseract.js ships its own type definitions, so you do not need an extra `@types` package.

```bash
npm install tesseract.js@5.1.1
```

```ts
// ocr.ts
import { createWorker, PSM, type Worker } from 'tesseract.js';

export interface OcrResult {
  text: string;
  confidence: number;
}

let worker: Worker | null = null;

async function getWorker(langs: string[]): Promise<Worker> {
  if (!worker) {
    worker = await createWorker(langs, 1);
    await worker.setParameters({ tessedit_pageseg_mode: PSM.AUTO });
  } else {
    await worker.reinitialize(langs);
  }
  return worker;
}

export async function imageToText(
  image: File | Blob | HTMLCanvasElement | string,
  langs: string[] = ['eng'],
): Promise<OcrResult> {
  const w = await getWorker(langs);
  const { data } = await w.recognize(image);
  return { text: data.text.trim(), confidence: data.confidence };
}

export async function disposeOcr(): Promise<void> {
  await worker?.terminate();
  worker = null;
}
```

Using it in a React component:

```tsx
import { useState } from 'react';
import { imageToText } from './ocr';

export function ImageToText() {
  const [text, setText] = useState('');
  const [busy, setBusy] = useState(false);

  async function onChange(e: React.ChangeEvent<HTMLInputElement>) {
    const file = e.target.files?.[0];
    if (!file) return;
    setBusy(true);
    try {
      const result = await imageToText(file, ['eng']);
      setText(result.text);
    } finally {
      setBusy(false);
    }
  }

  return (
    <div>
      <input type="file" accept="image/*" onChange={onChange} disabled={busy} />
      <textarea value={text} readOnly rows={12} />
    </div>
  );
}
```

The same `ocr.ts` works in Vue, Svelte, Angular or plain TypeScript, because it only depends on Tesseract.js.

## Use Tesseract in Node.js

Tesseract.js also runs in Node.js, with no native install:

```js
// ocr.mjs, run with: node ocr.mjs invoice.png
import { createWorker } from 'tesseract.js';

const worker = await createWorker('eng');
const { data } = await worker.recognize(process.argv[2]);
console.log(data.text);
await worker.terminate();
```

For heavy server workloads the native `tesseract` CLI is faster. You can call it from Node with `child_process.execFile('tesseract', [file, 'stdout', '-l', 'eng'])`. Always pass the arguments as an array, and never build a shell string from user input.

## Use Tesseract with PHP

PHP cannot run Tesseract inside the browser, so there are two different patterns. Pick the one that matches your privacy needs.

### Pattern A: OCR on the server with native Tesseract

Install Tesseract on the server (see above), then use the [`thiagoalessio/tesseract_ocr`](https://github.com/thiagoalessio/tesseract-ocr-for-php) wrapper:

```bash
composer require thiagoalessio/tesseract_ocr
```

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use thiagoalessio\TesseractOCR\TesseractOCR;

$text = (new TesseractOCR('uploads/receipt.jpg'))
    ->lang('eng', 'fra')
    ->psm(6)
    ->run();

echo nl2br(htmlspecialchars($text));
```

Without Composer, call the binary and escape the path with `escapeshellarg()`:

```php
<?php
$image = '/var/www/uploads/receipt.jpg';
$cmd = 'tesseract ' . escapeshellarg($image) . ' stdout -l eng 2>/dev/null';
$text = (string) shell_exec($cmd);
```

Before you put server side OCR in production:

- validate the upload (real image MIME type, size limit),
- store uploads outside the web root and delete them after OCR,
- limit concurrency, because Tesseract uses a lot of CPU,
- tell users their file is uploaded and how long you keep it.

### Pattern B: PHP renders the page, OCR runs in the browser

This is how QuickImageToText works. PHP never touches the image. It only prints the HTML and the configuration the JavaScript needs, so limits and languages are defined in one place:

```php
<?php
// config.php: the single source of truth
return [
    'max_image_mb'  => 10,
    'ocr_languages' => ['eng' => 'English', 'fra' => 'French', 'ara' => 'Arabic'],
    'tessdata_path' => '/tessdata/4.1.0',
];
```

```php
<?php
// page.php
$config = require __DIR__ . '/config.php';
?>
<input type="file" id="file" accept="image/*">
<pre id="output"></pre>

<script>
  window.OCR_CONFIG = <?= json_encode($config, JSON_HEX_TAG | JSON_UNESCAPED_UNICODE) ?>;
</script>
<script src="/vendor/tesseract/tesseract.min.js" defer></script>
<script src="/js/ocr.js" defer></script>
```

```js
// /js/ocr.js
document.getElementById('file').addEventListener('change', async (e) => {
  const file = e.target.files[0];
  if (!file) return;
  if (file.size > OCR_CONFIG.max_image_mb * 1024 * 1024) {
    alert(`Max ${OCR_CONFIG.max_image_mb} MB`);
    return;
  }
  const worker = await Tesseract.createWorker('eng', 1, { langPath: OCR_CONFIG.tessdata_path });
  const { data } = await worker.recognize(file);
  document.getElementById('output').textContent = data.text;
  await worker.terminate();
});
```

You get no uploads, no server CPU per image, no stored user files, and it runs on cheap shared hosting.

## Python in a few lines

[pytesseract](https://github.com/madmaze/pytesseract) wraps the native binary, so install Tesseract first:

```bash
pip install pytesseract pillow
```

```python
from PIL import Image
import pytesseract

print(pytesseract.image_to_string(Image.open("page.png"), lang="eng+fra"))
```

## Languages and traineddata models

Each language is a separate `.traineddata` file. There are three official sets:

| Set | Size per language | Accuracy | Speed | Good for |
|---|---|---|---|---|
| [`tessdata_fast`](https://github.com/tesseract-ocr/tessdata_fast) | about 0.6 to 2 MB | Good | Fastest | Latin, Cyrillic, web apps |
| [`tessdata`](https://github.com/tesseract-ocr/tessdata) (default) | medium | Better | Medium | General use, includes legacy engine data |
| [`tessdata_best`](https://github.com/tesseract-ocr/tessdata_best) | about 3 to 13 MB | Best | Slowest | Arabic, Urdu, Hindi, Bengali, Chinese, Japanese, Korean, Thai |

A few things worth knowing:

- Combine languages with `+`, like `fra+eng` or `ara+eng`. Two or three is fine. More slows things down and can lower accuracy.
- Language codes are three letters, not two: `eng`, `fra`, `deu`, `spa`, `ara`, `chi_sim`, `chi_tra`, `jpn`, `kor`, `hin`, `urd`.
- Chinese and Japanese also have vertical text models, such as `jpn_vert`.
- For the web, gzip the models and serve them with long cache headers.

## Page segmentation modes (PSM) explained

| PSM | Meaning | Use it for |
|---|---|---|
| 0 | Orientation and script detection only | Finding rotation or writing system |
| 1 | Automatic with OSD | Rotated scans |
| 3 | Fully automatic (default) | Documents, mixed layouts |
| 4 | Single column, variable sizes | Receipts, invoices |
| 6 | Single uniform block | Screenshots, paragraphs, book pages |
| 7 | Single text line | A heading, a serial number, one line of code |
| 8 | Single word | One word in a cropped image |
| 11 | Sparse text, any order | Signs, posters, labels, memes |
| 13 | Raw line, no heuristics | Unusual fonts on one line |

If the result is empty or scrambled, try PSM 6, 4 and 11 before anything else.

## Problems I faced and how I fixed them

These are real issues from building QuickImageToText. They apply to almost any Tesseract project.

### 1. Non English text came out as garbage

**Problem:** someone reading a Russian or Arabic image on the English page got nonsense, because OCR silently used English. Five languages people wanted (Urdu, Persian, Hindi, Bengali, Thai) were not offered at all, so they were read with the wrong model.

**Fix:** I added those languages and switched complex scripts to `tessdata_best` models. Then I built an Auto mode. OSD detects the writing system, and the tool tries the most likely language sets in order: the detected script, the visitor's browser languages, related languages such as Russian and Ukrainian or Arabic, Urdu and Persian, and English last. A result is accepted when it is confident and most of its letters really are in the expected script. Otherwise the best of at most 3 attempts wins. Latin text read as English is re-read as French, Spanish, German, Italian or Portuguese when common words give the language away. Users can still pick up to 3 languages by hand.

Choosing the right language matters more than any other setting. If you build an OCR tool, never hide the language choice.

### 2. Rotated and tilted photos failed completely

**Problem:** a phone photo turned 90 or 180 degrees produced almost nothing, and slightly tilted pages lost many words.

**Fix:** OSD reports quarter turns (90, 180, 270), which I apply before recognition. A low confidence turn is kept only if it actually reads better. Then a deskew step finds the small tilt, up to 15 degrees either way, with a projection profile and straightens the image.

### 3. Phone photos with shadows and a desk around the page

**Problem:** Tesseract's built in black and white step got confused by uneven light. Dark corners became "ink" and faint text disappeared.

**Fix:** a preprocessing step before Tesseract. It converts to grayscale, detects light text on a dark background and inverts it, normalises the lighting (the shadowed desk around a photographed page is painted white), stretches the contrast, and upscales when text lines are under about 20 pixels tall. That is roughly 300 dpi, where Tesseract works best. An optional black and white (Otsu) toggle helps on noisy scans.

### 4. The page froze during OCR

**Problem:** image processing and model downloads on the main thread blocked scrolling and clicks.

**Fix:** everything heavy runs in Web Workers. Preprocessing uses OffscreenCanvas inside a worker, which also downloads, unzips and caches the models. I measured no main thread pause over 25 ms during OCR, even with a cold 13 MB Japanese model. Browsers without OffscreenCanvas fall back to sending the original image to Tesseract with its own auto rotate.

### 5. Large model downloads on every visit

**Problem:** the best models are several MB each. Downloading them on page load would slow down every visitor, even the ones who never run OCR.

**Fix:** nothing loads when the page opens. Warm up starts when a file is chosen, pasted or dropped. Models are gzipped, served with a one year immutable cache from versioned folders, and stored in IndexedDB, so a returning visitor downloads nothing. The progress bar shows real bytes, so a slow connection does not look broken.

### 6. Results looked wrong even when OCR was right

**Problem:** correct Chinese, Japanese or Urdu text sometimes showed in the wrong font style, and the `best` CJK models put spaces between characters.

**Fix:** the result box gets the right `lang` attribute (`ja`, `zh-Hant`, `ur`) so the browser picks matching glyph forms. A self hosted Noto font stack loads only the scripts present on screen. The extra spaces between CJK characters are removed, except in Korean, which uses real spaces.

### 7. iPhone HEIC photos

**Problem:** most browsers cannot decode HEIC, so iPhone photos failed.

**Fix:** HEIC and HEIF files are converted to JPEG in the browser with a self hosted copy of [heic2any](https://github.com/alexcorvi/heic2any) before OCR. The file still never leaves the device.

### 8. Downloaded text opened with broken characters

**Problem:** a `.txt` file with Arabic or Chinese opened as mojibake in some editors, mostly on Windows.

**Fix:** downloads are written as UTF-8 with a BOM, which tells editors the encoding.

### 9. Word and character counts were wrong for Asian languages

**Problem:** splitting on spaces counts a whole Chinese or Thai paragraph as one word.

**Fix:** `Intl.Segmenter` counts real words and characters (graphemes) in every language.

### 10. Ad scripts broke the main button

**Problem:** some third party ad zones put invisible popup overlays on the page, so clicking "Extract text" opened an ad instead.

**Fix:** I turned those zones off. If your OCR tool shows ads, test the main action with the ads running.

### The result

On my set of 40 test images in 16 languages (clean scans, phone photos and rotated pages), the average character error rate dropped from about 42% to under 2% when the right language is selected or detected. The one hard case left is Urdu in Nastaliq, the flowing calligraphic style of the script, because Tesseract's Urdu model was trained mostly on the plainer Naskh style.

## Tips to get better OCR results

1. Choose the language, or a combination like `fra+eng`, instead of guessing.
2. Use good light with no shadows, and hold the phone parallel to the page.
3. Crop to just the text you need.
4. Aim for text 20 to 40 pixels tall. Upscale small text, and do not feed in huge 50 MP photos.
5. Straighten the image: rotate and deskew before OCR.
6. Keep contrast high: dark text on a light background. Invert white on black screenshots.
7. Try black and white (binarize) for noisy scans and faded print.
8. Pick the right PSM: 6 for a block, 7 for one line, 11 for scattered text.
9. Use PNG for screenshots. JPEG artifacts around small letters hurt accuracy.
10. Watch the confidence score. Below about 60%, retake the photo or change the language.

The official [Improving the quality of the output](https://tesseract-ocr.github.io/tessdoc/ImproveQuality.html) page goes deeper on each of these.

## Limitations you should know

- **Handwriting:** Tesseract is trained on printed text. Neat block capitals can work, cursive usually does not. QuickImageToText has a separate [handwriting to text](https://quickimagetotext.com/handwritten-to-text) page with tips for this case.
- **Complex layouts:** tables, forms and multi column magazines may need cropping or post processing. TSV output gives you word positions to work with.
- **Stylised fonts and logos:** decorative or very thin fonts can fail.
- **Urdu Nastaliq:** readable, but less accurate than Naskh style Arabic script.
- **Maths formulas and music notation:** not supported.
- **Very low resolution or blurred images:** no setting can recover text the pixels do not contain.

## FAQ

### Is Tesseract OCR free?

Yes. Tesseract and Tesseract.js are open source under the Apache 2.0 licence, free for personal and commercial use. QuickImageToText is also free, with no sign up.

### How does Tesseract work in a browser?

Tesseract.js compiles the Tesseract engine to WebAssembly and runs it in a Web Worker. The language model is downloaded once and cached, then the image is read entirely on your device.

### Does Tesseract upload my image to a server?

Not when it runs as Tesseract.js in the browser or as a program on your computer. On QuickImageToText the image is processed in your browser and never uploaded.

### How do I extract text from an image for free?

Open [QuickImageToText](https://quickimagetotext.com) and choose, paste or drop an image. The text appears a few seconds later. To do it locally, install Tesseract and run `tesseract image.png stdout`.

### How do I use Tesseract in JavaScript?

Install `tesseract.js` or add its script tag, create a worker with `createWorker('eng')`, call `worker.recognize(image)` and read `data.text`. The [JavaScript section](#extract-text-from-an-image-with-javascript) has a full example.

### Can I use Tesseract with TypeScript?

Yes. Tesseract.js includes its own TypeScript types. Import `createWorker` and `PSM` from `tesseract.js`.

### How do I use Tesseract with PHP?

Either install Tesseract on the server and use the `thiagoalessio/tesseract_ocr` Composer package, or let PHP render the page and run Tesseract.js in the browser so nothing is uploaded.

### Which languages does Tesseract support?

More than 100 languages and scripts. QuickImageToText offers 19 of them, including Arabic, Chinese, Japanese, Korean, Hindi, Urdu and Thai.

### Can Tesseract detect the language automatically?

Its OSD model detects the writing system (Latin, Arabic, Han and so on), not the exact language. Tools like QuickImageToText combine script detection with other hints to pick a language.

### Why is my OCR result wrong or empty?

Usually it is the wrong language, a rotated or blurry photo, very small text, or the wrong page segmentation mode. The [tips above](#tips-to-get-better-ocr-results) cover each one.

### Can Tesseract read handwriting?

Only neat, print style handwriting, and not reliably. It is built for printed text.

### Can Tesseract read PDFs?

Not directly. Convert each page to an image first, or use a tool that reads the PDF's text layer and only runs OCR on scanned pages, like the [QuickImageToText PDF to text tool](https://quickimagetotext.com/pdf-to-text).

### What is the difference between tessdata_fast and tessdata_best?

`fast` models are small and quick. `best` models are larger and more accurate. Use `best` for complex scripts like Arabic, Hindi and Chinese.

### Is Tesseract.js slower than native Tesseract?

Somewhat, because WebAssembly runs inside the browser sandbox. For normal photos and screenshots it still takes only a few seconds, and you save the upload time.

### Does Tesseract work offline?

Installed on your computer, yes. Tesseract.js can work offline once its files are cached, if the app is built for that. QuickImageToText itself needs a connection to load the page and the models.

---

Want to see all of this in action? [Extract text from an image](https://quickimagetotext.com) right in your browser, with no upload and no sign up. If you need OCR or another browser based tool built into your own product, [get in touch](/contact/).
