skillfed

langcodes

Tools for labeling human languages with IETF language tags

langcodes v3.5.1 12.5M downloads/30d#1,314 on PyPI31
Permissive license Active released

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 langcodes

uv

uv add langcodes

poetry

poetry add langcodes

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9

Tags

language code parsingIETF language tagsBCP 47 standardizationlanguage tag normalizationISO 639 language codeslanguage code validationmultilingual language identification
language-processinginternationalizationstandards-compliant

More Linguistic packages