langdetect
Language detection library ported from Google's language-detection.
What it is and what it does
langdetect is a Python port of Google's language-detection library, ported from Java. It identifies the language of input text and returns either a single language code (ISO 639-1 format) or a ranked list of candidate languages with confidence scores. The library supports 55 languages out of the box, including common European, Asian, and other language families.
The package depends only on six for Python 2/3 compatibility. Its core limitation is that the detection algorithm is non-deterministic—short or ambiguous text may produce different results across runs unless you seed the detector factory. It's designed for straightforward language identification tasks where you need quick results without external API calls or heavy dependencies.
Use it for:
- Automatically categorize user-generated content by language for multilingual applications or content moderation systems.
- Route text to language-specific processing pipelines (spell-checkers, NLP models, translation services) based on detected language.
- Identify the language of incoming support tickets or messages to assign them to appropriate language teams.
- Filter or segment documents in mixed-language datasets during data preprocessing for machine learning.
- Build language-aware search or recommendation features that adapt results based on detected user input language.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Detects the language of text input, supporting 55 languages and returning either a language code or probability scores for candidate languages.
Yes, if you need lightweight, dependency-minimal language detection without external API calls. The library is stable and permissively licensed, but consider it aging—last release was 2021. It's suitable for production use in applications where non-determinism on ambiguous text is acceptable and you don't require state-of-the-art accuracy. For modern alternatives or higher accuracy, evaluate current options.
Install
langdetect on PyPI
pip
pip install langdetectuv
uv add langdetectpoetry
poetry add langdetectInstalling langdetect
Before you install
Low install friction with a single lightweight dependency (six). Maintenance is aging—last release was in 2021 and the last commit was 2025-03-03, but the repository remains active and unarchived with stable production status.
License in practice
Licensed under MIT (permissive), allowing free use, modification, and distribution with minimal restrictions.
Quickstart
pip install langdetect
from langdetect import detect, detect_langs
detect("War doesn't show who's right, just who's left.")
detect_langs("Otec matka syn.")
Language detection is non-deterministic; for consistent results, set DetectorFactory.seed = 0 before first detection.
Verify before relying
- Current accuracy and performance characteristics compared to modern language detection libraries.
- Whether the library is actively maintained or in maintenance-only mode given the 2021 latest release date.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — six |
| Maintenance | aging — 1,925 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 11,081,342/month — #1,417 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: langdetect-1.0.9-py2-none-any.whl
Keywords: language, detection, library
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
fasttext-langdetectIdentifies the language of UTF-8 text using…
permissive · top 15,000 on PyPI
lingua-language-detectorDetects which language a text is written in,…
permissive · top 5,000 on PyPI
spacy-language-detectionAdds language detection to spaCy pipelines at…
copyleft · top 5,000 on PyPI
py3langidIdentifies the language of text in one of 97…
permissive · top 15,000 on PyPI
langidIdentifies the language of text input across 97…
permissive · top 15,000 on PyPI
silpa_commonProvides common utility functions for SILPA,…
copyleft · top 15,000 on PyPI
gcld3Identifies the language of input text using a…
unclear · top 15,000 on PyPI
pycld2Detects the language of text using Google's…
permissive · top 15,000 on PyPI
fast-langdetectDetects the language of text using FastText…
permissive · top 5,000 on PyPI
stopwordsisoProvides stopword lists for multiple languages…
permissive · top 15,000 on PyPI