# Text Language Detector: Find the Language of Any Text, 55 Langs (`kotaro-project/text-language-detector`) Actor

Detect the language of sentences, reviews, comments or paragraphs. Returns the ISO 639-1 code, language name, probability and runner-up languages for 55 languages, incl. English, Japanese, Chinese and Korean. Fast, offline, no API key. Pay only per text detected.

- **URL**: https://apify.com/kotaro-project/text-language-detector.md
- **Developed by:** [KOTARO project](https://apify.com/kotaro-project) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 1,000 text detecteds

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

## 🌐 Text Language Detector — find the language of any text

Give it sentences, reviews, comments or paragraphs. Get back the language of each one: the ISO 639-1 code, the language name, how sure the detector is, and the runner-up languages. Fast, offline, no API key.

### What it does

- 🌏 **55 languages**, including English, Japanese, Chinese (Simplified and Traditional), Korean, Spanish, French, German, Arabic, Hindi and Russian
- 🎯 **Probability and a `reliable` flag** for each text, so you can filter out guesses
- 🥈 **Runner-up languages** for mixed or short texts
- 🔁 **Same text, same answer** on every run
- ⚡ **Fast**: thousands of texts per run, no outside service is called

Good for sorting reviews and support tickets by language, cleaning datasets before translation, or routing messages to the right team.

### Input

| Field | What it is |
|---|---|
| `texts` | A list of texts to check (up to 10,000 per run) |

```json
{ "texts": ["The weather is lovely today, let's go for a walk.", "今日は雨なので、帰りにパン屋さんに寄ります。"] }
```

### Output

One row per text, in the same order:

```json
{
  "text": "今日は雨なので、帰りにパン屋さんに寄ります。",
  "chars": 22,
  "ok": true,
  "language": "ja",
  "languageName": "Japanese",
  "probability": 1.0,
  "reliable": true,
  "alternatives": []
}
```

Texts with too few letters (for example "123" or "!!") return `ok: false` with a short `error`.

### Pricing

Pay per event: **one `text` event per text whose language was detected**. Texts that could not be detected and empty runs are free.

### Limits

- Very short texts (a few words) can be guessed wrong; check `reliable`
- Only the first 10,000 characters of each text are used, and the first 500 characters are echoed back in `text`
- A run stops checking new texts after about 4.5 minutes and marks the rest to run again

### Credits

Detection uses the open-source langdetect library (Apache License 2.0).

# Actor input Schema

## `texts` (type: `array`):

Sentences, reviews, comments or paragraphs to check. One result row per text, in the same order. Up to 10,000 texts per run; only the first 10,000 characters of each text are used.

## Actor input object example

```json
{
  "texts": [
    "The weather is lovely today, let's go for a walk.",
    "今日は雨なので、帰りにパン屋さんに寄ります。",
    "Je voudrais un café, s'il vous plaît.",
    "Wie spät ist es jetzt?",
    "¿Dónde está la estación de tren?",
    "오늘 날씨가 정말 좋네요."
  ]
}
```

# 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 = {
    "texts": [
        "The weather is lovely today, let's go for a walk.",
        "今日は雨なので、帰りにパン屋さんに寄ります。",
        "Je voudrais un café, s'il vous plaît.",
        "Wie spät ist es jetzt?",
        "¿Dónde está la estación de tren?",
        "오늘 날씨가 정말 좋네요."
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kotaro-project/text-language-detector").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 = { "texts": [
        "The weather is lovely today, let's go for a walk.",
        "今日は雨なので、帰りにパン屋さんに寄ります。",
        "Je voudrais un café, s'il vous plaît.",
        "Wie spät ist es jetzt?",
        "¿Dónde está la estación de tren?",
        "오늘 날씨가 정말 좋네요.",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("kotaro-project/text-language-detector").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 '{
  "texts": [
    "The weather is lovely today, let'\''s go for a walk.",
    "今日は雨なので、帰りにパン屋さんに寄ります。",
    "Je voudrais un café, s'\''il vous plaît.",
    "Wie spät ist es jetzt?",
    "¿Dónde está la estación de tren?",
    "오늘 날씨가 정말 좋네요."
  ]
}' |
apify call kotaro-project/text-language-detector --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kotaro-project/text-language-detector"
        }
    }
}
```

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/eCfNXvp68VnhS443e/builds/tgkz7usmBUMRaB49W/openapi.json
