This guide explains how to use all the functionality the OCR API provides.

Basic OCR usage

The OCR API enables you to take files in any supported format and extract text to make it selectable and searchable. This is useful for images and scanned documents. To learn more about OCR itself, refer to the Wikipedia article on optical character recognition(opens in a new tab).

To run OCR on a single image file, add a page1.jpg file to the same folder as your code. You can use any image containing text, or use the sample page.

Run the code to get a result.pdf with your page OCRed. The example sets the OCR language to English. If your content is in a different language, update the language property accordingly. Refer to the supported languages section for a list of all available languages.

Below is the code to perform OCR:

Terminal window
curl -X POST https://api.nutrient.io/processor/ocr \
-H "Authorization: Bearer your_api_key_here" \
-o result.pdf \
--fail \
-F file=@page1.jpg \
-F data='{
"language": "english"
}'

Running OCR on multiple pages

While running OCR on a single page is useful, often you’ll have a folder full of scanned pages that you want to both run OCR on and merge into a single searchable PDF.

Pass in multiple images — one for each page in your request — and Nutrient DWS Processor API will merge all of them into a PDF before running OCR on it.

Add more files in the same folder as your code and run the updated code. You can duplicate and rename the existing file you have, or you can add some other images containing text.

Below is the code to perform OCR on multiple pages:

Terminal window
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer your_api_key_here" \
-o result.pdf \
--fail \
-F page1.jpg=@/path/to/page1.jpg \
-F page2.jpg=@/path/to/page2.jpg \
-F page3.jpg=@/path/to/page3.jpg \
-F page4.jpg=@/path/to/page4.jpg \
-F instructions='{
"parts": [
{
"file": "page1.jpg"
},
{
"file": "page2.jpg"
},
{
"file": "page3.jpg"
},
{
"file": "page4.jpg"
}
],
"actions": [
{
"type": "ocr",
"language": "english"
}
]
}'

Supported languages

The OCR action supports more than 80 languages for text extraction. You can specify languages using one of the following:

  • Full language name (lowercase, e.g. english, german) — available for commonly used languages
  • ISO 639-2 language code (e.g. eng, deu) — available for all languages
  • ISO 639-2 language code with variant (e.g. chi_sim_vert or deu_frak)
DescriptionLanguage codeFull language name
🇿🇦 Afrikaansafr
🇦🇱 Albaniansqi
🇪🇹 Amharicamh
🇸🇦 Arabicara
🇦🇲 Armenianhye
🇮🇳 Assameseasm
🇦🇿 Azerbaijaniaze
🇦🇿 Azerbaijani — Cyrillicaze_cyrl
🇪🇸 Basqueeus
🇧🇾 Belarusianbel
🇧🇩 Bengaliben
🇧🇦 Bosnianbos
🇫🇷 Bretonbre
🇧🇬 Bulgarianbul
🇲🇲 Burmesemya
🇪🇸 Catalan; Valenciancat
🇵🇭 Cebuanoceb
🇰🇭 Central Khmerkhm
🇺🇸 Cherokeechr
🇨🇳 Chinese — Simplifiedchi_sim
🇨🇳 Chinese — Simplified (Vertical)chi_sim_vert
🇹🇼 Chinese — Traditionalchi_tra
🇹🇼 Chinese — Traditional (Vertical)chi_tra_vert
🇫🇷 Corsicancos
🇭🇷 Croatianhrvcroatian
🇨🇿 Czechcesczech
🇩🇰 Danishdandanish
🇩🇰 Danish — Frakturdan_frak
🇲🇻 Dhivehi; Maldiviandiv
🇳🇱 Dutch; Flemishnlddutch
🇧🇹 Dzongkhadzo
🇬🇧 Englishengenglish
🇬🇧 English, Middle (1100–1500)enm
Esperantoepo
🇪🇪 Estonianest
🇫🇴 Faroesefao
🇵🇭 Filipinofil
🇫🇮 Finnishfinfinnish
🇫🇷 Frenchfrafrench
🇫🇷 French, Middle (ca. 1400–1600)frm
🇪🇸 Galicianglg
🇬🇪 Georgiankat
🇬🇪 Georgian — Oldkat_old
🇩🇪 Germandeugerman
🇩🇪 German — Frakturdeu_frak
🇩🇪 German Frakturfrk
🇬🇷 Greek, Ancientgrc
🇬🇷 Greek, Modernell
🇮🇳 Gujaratiguj
🇭🇹 Haitian; Haitian Creolehat
🇮🇱 Hebrewheb
🇮🇳 Hindihin
🇭🇺 Hungarianhun
🇮🇸 Icelandicisl
🇮🇩 Indonesianindindonesian
🇨🇦 Inuktitutiku
🇮🇪 Irishgle
🇮🇹 Italianitaitalian
🇮🇹 Italian — Oldita_old
🇯🇵 Japanesejpn
🇯🇵 Japanese (Vertical)jpn_vert
🇮🇩 Javanesejav
🇮🇳 Kannadakan
🇰🇿 Kazakhkaz
🇰🇬 Kirghiz; Kyrgyzkir
🇰🇷 Koreankor
🇰🇷 Korean (Vertical)kor_vert
🇮🇶 Kurdishkur
🇹🇷 Kurmanji (Kurdish)kmr
🇱🇦 Laolao
🇻🇦 Latinlat
🇱🇻 Latvianlav
🇱🇹 Lithuanianlit
🇱🇺 Luxembourgishltz
🇲🇰 Macedonianmkd
🇲🇾 Malaymsamalay
🇮🇳 Malayalammal
🇲🇹 Maltesemlt
🇳🇿 Maorimri
🇮🇳 Marathimar
Math/equation detectionequ
🇲🇳 Mongolianmon
🇳🇵 Nepalinep
🇳🇴 Norwegiannornorwegian
🇫🇷 Occitanoci
🇮🇳 Oriyaori
🇮🇳 Panjabi; Punjabipan
🇮🇷 Persianfas
🇵🇱 Polishpolpolish
🇵🇹 Portugueseporportuguese
🇦🇫 Pushto; Pashtopus
🇵🇪 Quechuaque
🇷🇴 Romanian; Moldavianron
🇷🇺 Russianrus
🇮🇳 Sanskritsan
🇬🇧 Scottish Gaelicgla
🇷🇸 Serbiansrpserbian
🇷🇸 Serbian – Latinsrp_latn
🇵🇰 Sindhisnd
🇱🇰 Sinhala; Sinhalesesin
🇸🇰 Slovakslkslovak
🇸🇰 Slovak – Frakturslk_frak
🇸🇮 Slovenianslvslovenian
🇪🇸 Spanish; Castilianspaspanish
🇪🇸 Spanish – Oldspa_old
🇮🇩 Sundanesesun
🇰🇪 Swahiliswa
🇸🇪 Swedishsweswedish
🇸🇾 Syriacsyr
🇵🇭 Tagalogtgl
🇹🇯 Tajiktgk
🇮🇳 Tamiltam
🇷🇺 Tatartat
🇮🇳 Telugutel
🇹🇭 Thaitha
🇨🇳 Tibetanbod
🇪🇷 Tigrinyatir
🇹🇴 Tongaton
🇹🇷 Turkishturturkish
🇨🇳 Uighur; Uyghuruig
🇺🇦 Ukrainianukr
🇵🇰 Urduurd
🇺🇿 Uzbekuzb
🇺🇿 Uzbek - Cyrillicuzb_cyrl
🇻🇳 Vietnamesevie
🇬🇧 Welshcym
🇳🇱 Western Frisianfry
🇮🇱 Yiddishyid
🇳🇬 Yorubayor