fast-langdetect
Quickly detect text language and segment language
What it is and what it does
fast-langdetect is a language detection library built on FastText that identifies the language of input text and returns a ranked list of language codes with confidence scores. It offers two model modes: a lite model (~45–60 MB) that works entirely offline, and a full model (~170–210 MB) that downloads on first use and provides higher accuracy. The library handles text normalization automatically (replacing newlines with spaces), truncates input to 80 characters by default to optimize accuracy, and falls back from the full model to the lite model only if memory runs out when using model='auto'.
The package is designed for low-friction integration: it requires no NumPy, installs as a pure Python wheel, and caches loaded models in memory within each detector instance to avoid reloading. You can use the global detect() function for simple cases or create a LangDetector instance with custom configuration (cache directory, input length limits, proxy settings) for more control. Language codes follow BCP-47 style (e.g., en, zh-cn, pt-br, yue), and the library provides examples for mapping codes to display names using langcodes or pycountry.
Use it for:
- Detect the language of user-submitted text in a web form or API to route it to the correct processing pipeline.
- Identify languages in multilingual documents to split or segment content by language before translation or analysis.
- Filter or categorize incoming messages by language in a chat or support system without external API calls.
- Validate that text input matches an expected language in a localized application.
- Build a language-aware search index that tags documents with their detected language for filtering or ranking.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Detects the language of text using FastText models, returning language codes and confidence scores with minimal dependencies and offline capability.
Yes. The package is actively maintained, has no known vulnerabilities, installs with low friction, and offers both offline and high-accuracy modes. Use it if you need fast, offline-capable language detection without heavy dependencies. The lite model is practical for memory-constrained environments; the full model is appropriate when accuracy matters more than footprint. MIT licensing poses no restrictions.
Install
fast-langdetect on PyPI
pip
pip install fast-langdetectuv
uv add fast-langdetectpoetry
poetry add fast-langdetectInstalling fast-langdetect
Before you install
Low friction: pure Python wheel with three runtime dependencies (robust-downloader, requests, fasttext-predict). Active maintenance with a release 100 days ago. Supports Python 3.9 through 3.14.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install fast-langdetect
from fast_langdetect import detect
result = detect("Hello, world!", model="auto", k=1)
print(result)
Models download to system temp by default; set FTLANG_CACHE environment variable or use LangDetectConfig(cache_dir=...) to customize storage location. Lite model (~45–60 MB) runs offline; full model (~170–210 MB) requires download.
Verify before relying
- Whether the 80x speed improvement and 95% accuracy claims are independently verified or measured against specific baselines.
- How accuracy varies across the 176 supported languages and whether performance degrades on short or mixed-script text.
- Whether robust-downloader, requests, and fasttext-predict have known security issues or maintenance concerns not visible in OSV.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — robust-downloader, requests, fasttext-predict |
| Maintenance | actively maintained — 100 days since the last release |
| First released | |
| Downloads | 4,349,178/month — #2,324 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fast_langdetect-1.0.1-py3-none-any.whl
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
fasttext-predictLoads and runs fastText language identification…
permissive · top 5,000 on PyPI
fasttextfastText is a library for learning word…
permissive · top 5,000 on PyPI
fasttext-numpy2fasttext-numpy2 provides Python bindings for…
permissive · top 5,000 on PyPI
fasttext-wheelfasttext-wheel provides Python bindings for…
permissive · top 5,000 on PyPI
langdetectDetects the language of text input, supporting…
permissive · top 5,000 on PyPI
langcodesParses, validates, and standardizes IETF…
permissive · top 5,000 on PyPI
py3langidIdentifies the language of text in one of 97…
permissive · top 15,000 on PyPI
floretfloret trains compact word embeddings using…
permissive · top 15,000 on PyPI
cnocrCnOCR recognizes text in images—Chinese…
permissive · top 15,000 on PyPI