# Image to Text OCR - Extract Text from Images, Screenshots, PDF (`gochujang/image-ocr-extractor`) Actor

Convert image to text or screenshot to text from public URLs. OCR PDF pages, scans, and photos with Tesseract; get recognized text and confidence scores in dataset records.

- **URL**: https://apify.com/gochujang/image-ocr-extractor.md
- **Developed by:** [Hojun Lee](https://apify.com/gochujang) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 128 total users, 48 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 image ocr extracteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## OCR Image to Text — OCR PDF and Screenshot to Text

Convert image to text or screenshot to text from public image URLs, and OCR PDF pages from PDF URLs. Tesseract returns recognized text and confidence scores for scans and documents.

### Quick start

Use this small, public image containing printed English text:

```json
{"urls":["https://jeroen.github.io/images/testocr.png"],"language":"eng","limit":1}
```

One dataset item from this input, with OCR text and confidence varying slightly by Tesseract version:

```json
{"index":1,"url":"https://jeroen.github.io/images/testocr.png","ok":true,"text":"This is a lot of 12 point text to test the ocr code and see if it works on all types of file format. The quick brown dog jumped over the lazy fox. The quick brown dog jumped over the lazy fox. The quick brown dog jumped over the lazy fox. The quick brown dog jumped over the lazy fox.","word_count":60,"char_count":284,"confidence_score":96.0,"auto_enhanced":false,"language":"eng","contains_numbers":true,"contains_emails":[],"contains_urls":[],"text_density":"medium","tables_detected":0,"tables":[],"total_pages":null,"pages":null,"error":null,"changed":null}
```

`ok` reports download and OCR success; `text` contains recognized words. `word_count` and `char_count` measure the recognized text. `confidence_score` is Tesseract's average word confidence; `auto_enhanced` shows whether a second preprocessing pass was used. `error` describes a failed item.

### Limits

Unreachable or unsupported image URLs produce error items. OCR quality depends on resolution, orientation, and font; handwriting and complex layouts may be unreliable. PDF processing depends on page count and can take longer than a single image. Use `limit` to bound a batch.

### Pricing

Pay-per-event:

| Event | Price |
|---|---|
| Actor start (charged by Apify, one per GB of run memory) | $0.001 |
| Image/PDF successfully OCR-processed | $0.002 |

The first 5 successful images per account are free (once, not per run); failed items are never charged. Example: 50 images = 50 × $0.002 = **$0.10** plus the start fee (after the free 5 are used up).

### Use from AI agents (MCP)

Connect your agent to [Apify's official MCP server](https://mcp.apify.com) with an Apify token. Select the Actor tool `gochujang/image-ocr-extractor`, pass the Quick start JSON as input, then retrieve its dataset items through the MCP server. No separate gateway is needed.

***

### What does Image OCR Extractor do?

**Image OCR Extractor** is an **image text extraction** API that converts any image — screenshot, invoice, receipt, form, or photo — into structured text using Tesseract OCR. Submit one image or a batch of up to 50 (PNG, JPG, WebP, TIFF, BMP), and receive extracted text plus a per-image confidence score. **No API key, no GPU, no setup required.**

This actor runs the full **extract text from images** pipeline automatically: download, preprocess, Tesseract recognition, and structured JSON output. When confidence is low, it retries with threshold preprocessing to improve accuracy — so you get the best result without any manual tuning.

***

### Why use Image OCR Extractor?

1. **Invoice and receipt digitization** — Extract totals, line items, vendor names, and dates from receipt photos or scanned invoices to feed accounting workflows automatically.
2. **Screenshot text extraction** — Turn UI screenshots, error messages, and social media screenshots into searchable, indexable text in seconds.
3. **Multilingual document processing** — Support for 100+ languages including Japanese, Chinese, Korean, German, French, and Spanish, with combined-language mode for bilingual documents.
4. **Form and survey digitization** — Process handwritten or typed paper forms from scanned documents without manual data entry.
5. **Batch data pipeline integration** — OCR entire image archives and feed the output into LLMs, databases, or search indexes programmatically via the Apify API.

***

### How to use Image OCR Extractor

1. Open the actor on Apify Store and click **Try for free**.
2. Paste one or more image URLs into the `url` or `urls` input field.
3. Select a language code (default: `eng`) and preprocessing mode (default: `grayscale`).
4. Click **Start** — results arrive in seconds.
5. Fetch structured JSON from the Apify dataset or connect via API for automation.

***

### Input

| Parameter | Type | Default | Description |
|---|---|---|---|
| `url` | string | — | Single image URL. Used when `urls` is empty. |
| `urls` | array | — | Batch list of image URLs (up to 50 per run). |
| `language` | string | `eng` | Tesseract language code: `eng`, `deu`, `fra`, `spa`, `jpn`, `chi_sim`, `kor`, or combined `eng+deu`. |
| `preprocessing` | string | `grayscale` | Image preprocessing: `none`, `grayscale`, or `threshold` (binarize). |
| `pageSegMode` | integer | `3` | Tesseract PSM: 3 = auto, 6 = block, 7 = line, 8 = word, 11 = sparse. |
| `limit` | integer | `50` | Max images to process per run (hard cap: 200). |

**Supported URL types**: direct image links, Google Drive share links, and Dropbox share links are all automatically resolved — no manual conversion needed.

***

### Output

Each processed image returns one JSON object:

```json
{
  "index": 1,
  "url": "https://example.com/invoice.png",
  "ok": true,
  "text": "Invoice #2024-001\nBill To: Acme Corp\nTotal: $1,250.00",
  "word_count": 9,
  "confidence_score": 87.4,
  "auto_enhanced": false,
  "language": "eng",
  "error": null
}
```

`auto_enhanced: true` means low confidence was detected on the first pass and the actor automatically re-ran OCR with threshold preprocessing. `error` is populated only when the image could not be processed at all.

***

### Data fields

| Field | Type | Description |
|---|---|---|
| `index` | integer | Position in the input list (1-based) |
| `url` | string | Source image URL |
| `ok` | boolean | Whether OCR succeeded |
| `text` | string | Extracted text (newline-separated) |
| `word_count` | integer | Number of words extracted |
| `confidence_score` | float | Tesseract average confidence score (0–100) |
| `auto_enhanced` | boolean | Whether automatic threshold preprocessing was applied |
| `language` | string | Language code used |
| `error` | string or null | Error message if OCR failed |

**Confidence score guide**:

| Range | Meaning |
|---|---|
| 85–100 | High quality, likely accurate |
| 60–84 | Moderate — review critical fields |
| < 60 | Low — actor automatically retries with threshold preprocessing |

***

### FAQ

**Does the OCR API support handwriting?**
Tesseract performs best on printed text. Handwriting recognition is possible but accuracy varies. Use `preprocessing: threshold` and `pageSegMode: 6` for best results on handwritten forms.

**Can I extract text from images with dark backgrounds or colored overlays?**
Yes. Use `preprocessing: grayscale` (the default) for colored or photographic backgrounds. For text printed on a white background, `threshold` gives sharper binarized results.

**How accurate is image text extraction?**
For clean, high-resolution images with standard fonts, confidence scores typically land in the 85–95 range. Low-quality photos or stylized fonts may score lower, but the automatic enhancement retry improves results without manual effort.

> **Disclaimer**: OCR accuracy depends on image quality, resolution, and font type. This actor is not intended for medical, legal, or financial document processing where 100% accuracy is required. Always verify extracted text for critical use cases.

***

### Works Great With

Build a complete document processing pipeline with these actors from the same author:

- **[PDF Text & Table Extractor](https://apify.com/gochujang/pdf-text-extractor)** — Extract text from PDF documents in the same pipeline. When your input is a mix of image files and PDFs, run both actors together — images go to OCR Extractor, PDFs go to the PDF actor — and merge results in a single dataset.
- **[DOCX Text Extractor](https://apify.com/gochujang/docx-text-extractor)** — For Word documents. Complete the trifecta: images (this actor), PDFs, and Word docs can all be normalized to plain text in one automated pipeline.
- **[Excel & CSV Extractor](https://apify.com/gochujang/excel-extractor)** — For spreadsheets. Digitize entire document archives — scan OCR images, extract PDFs, parse Excel files — and feed all output into the same downstream database or LLM.

***

### Run it on a schedule / from your pipeline

**1. Apify Schedule.** Apify Console → **Schedules** → **+ New schedule**, pick Image OCR Extractor, set a cron such as `0 6 * * 1-5` (weekdays 06:00 UTC) and paste this input:

```json
{
  "urls": [
    "https://example.com/scans/receipt-001.png",
    "https://example.com/scans/receipt-002.jpg"
  ],
  "language": "eng",
  "preprocessing": "grayscale",
  "outputFormat": "json"
}
```

**2. API call from your pipeline.** Run the actor and get the dataset items back in a single request:

```bash
curl -X POST "https://api.apify.com/v2/acts/gochujang~image-ocr-extractor/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d @input.json
```

`input.json` holds the same JSON as above. Synchronous runs wait up to 300 seconds; for bigger batches call `POST /v2/acts/gochujang~image-ocr-extractor/runs` and read the dataset when the run finishes.

**3. Webhooks.** For new-file triggers, have your storage or automation tool (S3 event, Zapier, Make, n8n) call the API above whenever a file arrives, and add an Apify webhook on `ACTOR.RUN.SUCCEEDED` (Actor → **Integrations**) to push the results to your system as soon as the run finishes.

***

### Related actors

- [PDF Text & Table Extractor](https://apify.com/gochujang/pdf-text-extractor) — PDF version with table detection, password-protected PDFs, batch processing
- [DOCX Text Extractor](https://apify.com/gochujang/docx-text-extractor) — Word document extraction, same URL/Drive/Dropbox pattern
- [Excel & CSV Extractor](https://apify.com/gochujang/excel-extractor) — .xlsx/.xls/.csv to JSON, full row/column structure
- [Web Page to Markdown Converter](https://apify.com/gochujang/web-to-markdown) — HTML text extraction

### Feedback

[Leave a review on Apify Store](https://apify.com/gochujang/image-ocr-extractor#reviews)

***

**Keywords:** image OCR, Tesseract OCR, PDF to text, screenshot OCR, receipt digitizer, document scanner, image text extraction, XLSX OCR, table extraction, multi-language OCR, PNG to text, JPG OCR, document automation

# Actor input Schema

## `urls` (type: `array`):

Public image or PDF URLs for OCR image to text, OCR PDF, or screenshot to text (PNG, JPG, WebP, TIFF, BMP, PDF). For a small test use https://jeroen.github.io/images/testocr.png. Google Drive and Dropbox share links are resolved to downloads.

## `url` (type: `string`):

Single public image or PDF URL for image to text, used when urls is empty; for example https://jeroen.github.io/images/testocr.png.

## `language` (type: `string`):

Tesseract language code. Leave empty for auto-detection. 'eng' (English), 'deu' (German), 'fra' (French), 'spa' (Spanish), 'jpn' (Japanese), 'chi_sim' (Simplified Chinese), 'kor' (Korean). Multi-language: 'eng+deu'.

## `preprocessing` (type: `string`):

Apply image preprocessing before OCR. 'none' = raw image. 'grayscale' = convert to grayscale (often improves accuracy). 'threshold' = binary black/white (best for documents with clear text on white background). 'deskew' = auto-rotate skewed scans.

## `pageSegMode` (type: `integer`):

Tesseract PSM. 3 = auto (default), 6 = single block of text, 7 = single line, 8 = single word, 11 = sparse text (scattered text). See Tesseract docs.

## `minConfidence` (type: `integer`):

Filter out words with OCR confidence below this threshold (0-100). Default 0 = include all words. Higher values (e.g. 60) reduce noise but may drop valid words.

## `limit` (type: `integer`):

Maximum number of images or PDFs to process (1-200).

## `outputFormat` (type: `string`):

'text' (default) = plain text string. 'json' = structured object with word_count, confidence_score, tables, pages etc. 'lines' = array of non-empty lines from the OCR result.

## `changeDetection` (type: `boolean`):

Compare OCR text hash against previous run (stored in named KVS 'image-ocr-change-detection'). Each result will include a 'changed' field: true = text changed since last run, false = unchanged, null = no previous data.

## `telegramBotToken` (type: `string`):

Telegram bot token (format: 123456:ABC-...). Used to send alerts when changeDetection=true and at least one image has changed. Leave empty to disable Telegram alerts.

## `telegramChatId` (type: `string`):

Telegram chat ID (user, group, or channel) to receive change alerts. Required when telegramBotToken is set.

## Actor input object example

```json
{
  "urls": [
    "https://jeroen.github.io/images/testocr.png"
  ],
  "url": "",
  "language": "",
  "preprocessing": "grayscale",
  "pageSegMode": 3,
  "minConfidence": 0,
  "limit": 50,
  "outputFormat": "text",
  "changeDetection": false,
  "telegramBotToken": "",
  "telegramChatId": ""
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://jeroen.github.io/images/testocr.png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gochujang/image-ocr-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": ["https://jeroen.github.io/images/testocr.png"] }

# Run the Actor and wait for it to finish
run = client.actor("gochujang/image-ocr-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://jeroen.github.io/images/testocr.png"
  ]
}' |
apify call gochujang/image-ocr-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gochujang/image-ocr-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/lLnKDJXM395nSyWXi/builds/3uEpUP1utBLZRsWq6/openapi.json
