--- id: fast-langdetect version: "1.0.1" license: MIT license_treatment: permissive maintenance: active --- # fast-langdetect — Quickly detect text language and segment language License: permissive · Maintenance: active · Downloads: 4.3M/mo ## 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 above — 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 pip install fast-langdetect uv add fast-langdetect poetry add fast-langdetect ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 4.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags language detection, detect text language, fasttext language identification, multilingual text detection, language recognition library, identify language from text, language classifier, nlp, language-detection, fasttext [View on SkillFed](https://skillfed.io/packages/fast-langdetect) · [View on PyPI](https://pypi.org/project/fast-langdetect/)