idna

Internationalized Domain Names for Python — IDNA 2008 and UTS #46 encoding and decoding

Library
PyPI
v3.20
299 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
81 /100 Excellent
Development Activity 96
Maintenance 72
Community 76
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
85 /100 Excellent
Architecture 85
Code Quality 88
Innovation 86
Learning Curve 72

idna is a pure-Python library implementing Internationalized Domain Names in Applications (IDNA 2008, RFC 5891) together with Unicode IDNA Compatibility Processing (UTS #46). It converts domain names between their Unicode representation (U-labels) and ASCII-compatible xn— encoding (A-labels), superseding the standard library’s older encodings.idna module.

With broader script coverage than the 2003 specification and built-in validation that rejects domains with known security issues, idna is a foundational dependency across the Python ecosystem, used by HTTP clients such as Requests, urllib3, and httpx to correctly handle non-ASCII domain names.

What You Get

  • encode() and decode() functions that convert whole domains between Unicode and ASCII-compatible xn— form
  • IDNA 2008 (RFC 5891) validation with bidirectional, contextual-joiner, and codepoint checks
  • Optional UTS #46 compatibility mapping (uts46=True) that normalizes user input before conversion
  • Per-label alabel/ulabel helpers and a registered idna2008 codec for str.encode('idna2008')
  • A command-line idna tool for converting domains from the shell or standard input

Common Use Cases

  • Normalizing and encoding non-ASCII hostnames before making network requests
  • Validating that a user-supplied domain conforms to IDNA 2008 rules
  • Displaying Unicode domain names decoded from their xn— Punycode form in user interfaces

Under The Hood

Architecture The public surface lives in idna/core.py, where encode() splits a domain on the four Unicode label separators via _unicode_dots_re, optionally applies UTS #46 remapping through uts46_remap() (backed by the generated tables in uts46data.py), then Punycode-encodes each label with alabel(); alabel() runs the full validation stack — check_label() enforces bidirectional rules (RFC 5893), hyphen and initial-combiner constraints, and contextual joiners (CONTEXTJ/CONTEXTO) — before prepending the xn-- prefix. decode() reverses the process, and codec.py registers a stateless idna2008 codec plus incremental encoder/decoder classes. Tech Stack It is pure Python targeting 3.9+ with zero runtime dependencies, leaning only on the standard library (unicodedata, bisect, re, codecs); it builds with the flit_core backend, ships a py.typed marker, and generates its large idnadata.py/uts46data.py lookup tables offline via the scripts in tools/. Development tooling is ruff (with bugbear, simplify, pyupgrade, and perflint rule sets), mypy, and pytest. Code Quality Codepoint membership is answered in O(log n) by intranges.py, which packs sorted ranges into single integers (start << 32 | end) and binary-searches them, and hot bidi category sets are hoisted to module-level frozensets to stay out of the per-codepoint loop. The code is fully type-annotated, exposes a clean exception hierarchy (IDNAError with IDNABidiError, InvalidCodepoint, InvalidCodepointContext), and is exercised by a tests/ suite covering core, UTS #46, the codec, the CLI, compat, and the intranges helper. API Design The surface is deliberately small and mirrors familiar codec naming: encode/decode for whole domains, alabel/ulabel per label, an uts46=True flag for compatibility mapping, and a display=True option for leaving undecodable labels intact in UIs. Registering the idna2008 codec lets callers use str.encode('idna2008'), and a bundled CLI plus a concise, example-driven README keep the getting-started boilerplate near zero.

Used by 25 apps in this directory

TypeScript
67%
MIT

Scalar

Developer Tools

16,313

Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.

View details
90
Repo Health
89
Technical
65
Dependency
Built with
TypeScript 67%
Vue 29%
Updated 6 days ago
TypeScript
47%
Other

Stirling PDF

Digital Signiture · Productivity

94,824

The open-source PDF platform you can run anywhere — edit, convert, sign, and automate PDFs without sending files to external servers.

View details
92
Repo Health
86
Technical
68
Dependency
Built with
TypeScript 47%
Java 44%
Updated 6 days ago
Python
94%
Apache 2.0

SWIRL

Data Engineering · Databases · Search

3,046

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
61
Repo Health
83
Technical
65
Dependency
Built with
Python 94%
Updated 1 weeks ago
Python
97%
MPL 2.0

Taiga Back

Developer Tools · Project Management

859

Self-hosted agile project management backend with Scrum, Kanban, issue tracking, and a full REST API — built on Django and PostgreSQL.

View details
72
Repo Health
74
Technical
64
Dependency
Built with
Python 97%
Updated 1 months ago
C
74%
AGPL 3.0

TDengine

Databases

25,168

A high-performance, open-source time-series database built in C for IoT, connected vehicles, and industrial monitoring workloads, with built-in stream processing, caching, and data subscription.

View details
97
Repo Health
71
Technical
65
Dependency
Built with
C 74%
C++ 19%
Updated 1 weeks ago
Python
73%
Apache 2.0

timesfm

AI Development · Analytics

34,750

A pretrained decoder-only foundation model by Google Research that delivers zero-shot time series forecasting with calibrated quantile prediction intervals — no training required.

View details
76
Repo Health
81
Technical
71
Dependency
Built with
Python 73%
HTML 14%
Jupyter Notebook 12%
Updated 1 months ago
Rust
33%
Other

Windmill

Automation · Developer Tools

18,257

Turn scripts into webhooks, workflows, and auto-generated UIs — the fastest self-hostable workflow engine, 13x faster than Airflow.

View details
91
Repo Health
82
Technical
64
Dependency
Built with
Rust 33%
TypeScript 24%
Svelte 22%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers