Detect a document's language
Know what a file is written in before anyone opens it: a contract with an English clause and a Spanish appendix comes back with both languages, ordered by how much of the document each covers. Failed detections are retried at no charge.
Run it online
Run this on our servers with your account. Free tools run in your browser; this one bills your KIT balance per the price above.
Sorting an unlabeled inbox of files by language is a small task that quietly blocks a much bigger pipeline, since translation, OCR and review tools all need to know what they're reading before they can do their job.
The routing problem nobody notices until it breaks
A support inbox, a legal intake folder, or a scanned-archive project rarely arrives labeled by language; a file just shows up, and every downstream step — which OCR model to run, which translator to queue, which reviewer speaks the language well enough to check it — depends on knowing the answer first. Guessing wrong wastes a processing pass entirely, and doing it by opening every file manually doesn't scale past a few dozen documents.
Why mixed-language documents are the real test
A single-language memo is the easy case; the harder and far more common one is a document that switches language mid-page — a contract with an English clause and a Spanish appendix, a form with printed labels in one language and handwritten answers in another, an email thread that drifts between languages as participants reply. Detecting language reliably means reading the whole document rather than sampling the first line, because the first line is exactly where a document is least likely to reveal what's on page four.
What you can do with it
Translation agency triage
An agency detects the language of every incoming client file before quoting or assigning it to a translator who works in that language.
Multinational support routing
A support team routes scanned correspondence to the regional office that handles its detected language instead of guessing from the sender's address.
Mixed-language archive sorting
A digitization project sorts a collection of unlabeled scanned documents by detected language before applying the correct OCR model to each group.
Compliance review assignment
A compliance team flags documents written in a language that requires sign-off from a specific reviewer before further processing.
FAQ
Can it detect more than one language in the same document?
Yes, it reads the full document and returns every language it finds, ordered by how much of the content each one accounts for.
Is there a free tier for language detection?
There's no free tier — free tiers get abused and slow everyone down. No subscription, no tokens, no invented credits, and a failed task is never charged.
Does it work on scanned or handwritten documents, not just typed text?
Yes, it reads scanned and handwritten pages as well as native digital text before identifying the language.
Am I charged if detection fails?
No. A failed task retries automatically up to three times and is never billed; you receive a clear error instead.
In what order are the languages listed for a mixed document?
By how much of the document each one covers, so the language that fills most of the pages comes first. The whole document is read, not just the first line, because later pages often hold the other language.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/ocr/language \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"El informe trimestral cerró con 1,2 M€ de ingresos."}'const res = await fetch("https://api.kit.forhosting.com/ocr/language", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "El informe trimestral cerró con 1,2 M€ de ingresos."
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/ocr/language",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"text": "El informe trimestral cerró con 1,2 M€ de ingresos."
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/ocr/language", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"text":"El informe trimestral cerró con 1,2 M€ de ingresos."}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"text":"El informe trimestral cerró con 1,2 M€ de ingresos."}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/ocr/language", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"text": "El informe trimestral cerró con 1,2 M€ de ingresos."
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "ocr.language",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_mb | 25 |
max_pages | 10 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
422 | task_failed | The task failed after 3 retries. You are never charged for it. |
Technical notes
This endpoint reads a document, identifies its language or languages, and returns that as JSON before anything downstream even opens the file.
Who needs to know the language before anything else
Translation agencies triaging an incoming batch of files from a client before quoting or assigning a translator, multinational support teams routing scanned correspondence to the right regional office, digital archives sorting a mixed-language collection before applying language-specific OCR models, and compliance teams flagging documents in a language that requires a specific reviewer's sign-off.
What comes back from the call
Submit the file to POST /ocr/language and receive a task_id immediately, since detection runs as an asynchronous task rather than blocking the request. The result — the detected language or languages, in order of how much of the document each one covers for mixed-language files — arrives by signed webhook or is available at a signed link for 24 hours.
Where it sits before everything else
At $0.003 per request plus $0.0135 per document, billed only when detection succeeds, this endpoint is cheap enough to run as the very first step in an intake pipeline, before OCR, before translation, before a document ever reaches a human queue — the detected language becomes the routing key for whatever happens next. A failed detection retries automatically up to three times at no charge, and access requires prepaid balance; there's no free tier, which keeps the endpoint responsive at intake volume.
Technical questions
What does the Document Language Detection API return?
The detected language or languages of the document as JSON, ordered by how much of the document each language covers when more than one is present.
How do I call the document language detection api?
Send the file to POST /ocr/language, get a task_id right away, and receive the detected language by webhook or a signed link once the async task completes.
How much does it cost to detect a document's language?
$0.003 per request plus $0.0135 per document, published pricing billed only when detection succeeds.
How is this different from just checking the file's metadata or locale?
Metadata and file locale often don't match the actual content language; this endpoint reads the text itself rather than trusting file properties.