langcodes
Tools for labeling human languages with IETF language tags
What it is and what it does
Langcodes is a library for working with IETF language tags (standardized codes like 'en' for English, 'es' for Spanish, 'zh-Hans-CN' for Simplified Chinese in China). It implements BCP 47, the standard that subsumes ISO 639 and handles language variations, scripts, territories, and deprecated codes. The library solves the problem of language code equivalence: it knows that 'eng' and 'en' refer to the same language, that 'en-UK' is a misspelling that should map to 'en-GB', and that redundant script tags like 'en-Latn' can be shortened to 'en'.
The package provides two main interfaces: a `standardize_tag()` function that converts any language tag to its canonical BCP 47 form, and a `Language` class that parses tags into structured components (language, script, territory, variants, extensions, and private use codes). It validates tags against the IANA subtag registry, replacing deprecated values and handling complex substitutions like converting Serbo-Croatian to Serbian in Latin script. With no runtime dependencies and active maintenance, it's a lightweight tool for any application that needs to normalize or validate language identifiers.
Use it for:
- Normalize user-provided language preferences in web applications or APIs to canonical BCP 47 format for consistent storage and comparison.
- Validate and correct language codes in multilingual content systems, replacing deprecated or misspelled codes with their modern equivalents.
- Parse language tags to extract components (language, script, territory) for conditional logic in localization or content delivery pipelines.
- Detect and handle language equivalences, such as treating 'zh-CN' and 'zh-Hans' interchangeably in Chinese text processing systems.
- Build language selection dropdowns or autocomplete that accepts multiple input formats and normalizes them to standard codes.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses, validates, and standardizes IETF language tags (BCP 47 format), converting between different representations of the same language and resolving deprecated or non-standard codes.
Yes. Langcodes is a stable, actively maintained library with no dependencies, permissive licensing, and strong popularity (top 5000 on PyPI). Install it if you work with language codes, multilingual systems, or need to normalize IETF language tags. The only minor consideration is whether you also need the optional language_data supplement for localized language names.
Install
langcodes on PyPI
pip
pip install langcodesuv
uv add langcodespoetry
poetry add langcodesInstalling langcodes
Before you install
Installs with no runtime dependencies and low friction. Active maintenance with a recent release (2025-12-02) and last commit on 2026-07-20. Supports current Python versions (3.9 through 3.13).
License in practice
Released under the MIT license (permissive), allowing free use, modification, and distribution with minimal restrictions.
Quickstart
pip install langcodes
from langcodes import standardize_tag, Language
# Standardize a tag
print(standardize_tag('eng_US')) # 'en-US'
# Parse and inspect a language
lang = Language.get('en-Latn-US')
print(lang.language, lang.script, lang.territory)
Requires Python 3.9 or later.
Verify before relying
- Whether the optional language_data supplement (mentioned in description) is required for full functionality or only for localized language names.
- Performance characteristics when processing large volumes of language tags.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 255 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 12,534,804/month — #1,314 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: langcodes-3.5.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
language-dataProvides multilingual language names, speaker…
permissive · top 5,000 on PyPI
language-tagsValidates and parses IANA language tags…
permissive · top 5,000 on PyPI
iso639-langResolves ISO 639 language codes and names to…
permissive · top 15,000 on PyPI
python-iso639Maps ISO 639 language codes (639-1, 639-2,…
permissive · top 5,000 on PyPI
babelfishBabelFish provides Python objects for…
permissive · top 15,000 on PyPI
iso-639Provides a Python interface to ISO 639 language…
agpl · top 15,000 on PyPI
rigourRigour provides data cleaning and validation…
permissive · top 15,000 on PyPI
stopwordsisoProvides stopword lists for multiple languages…
permissive · top 15,000 on PyPI
fast-langdetectDetects the language of text using FastText…
permissive · top 5,000 on PyPI
isocodesisocodes provides programmatic access to ISO…
permissive · top 15,000 on PyPI