Charset Normalizer

A pure-Python universal charset detector that turns text of unknown encoding into clean Unicode.

Library
PyPI
v3.5.1
788stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
83/100Excellent
Development Activity96
Maintenance96
Community52
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
88/100Excellent
Architecture88
Code Quality88
Innovation90
Learning Curve85

Charset Normalizer is a pure-Python library that detects the character encoding of arbitrary byte streams and normalizes their contents to Unicode. Motivated by the limitations of Chardet, it takes a fundamentally different, heuristic approach: instead of relying on trained statistical weights per encoding, it brute-forces decoding across every IANA-supported codec and scores each candidate by how much “mess” and how much linguistic coherence the decoded text exhibits.

Shipped under the permissive MIT license with zero runtime dependencies, it supports 99 encodings, can register custom codecs, detects the spoken language of the text, and guards against UnicodeDecodeError. It is one of the most widely installed packages in the Python ecosystem, serving as the default encoding detector behind the Requests HTTP client.

What You Get

  • A high-level Python API (from_path, from_bytes, from_fp) that returns ranked charset matches with a convenient .best() accessor
  • A normalizer command-line tool that prints JSON detection results and can rewrite files to Unicode
  • A chardet-compatible detect() function for zero-effort migration from Chardet
  • Support for 99 IANA encodings, custom codec registration, BOM/signature handling, and spoken-language detection

Common Use Cases

  • Decoding user-uploaded files, subtitles, or scraped web content whose encoding is unknown
  • Powering the automatic response-encoding detection inside HTTP clients such as Requests
  • Batch-normalizing legacy documents from mixed or unknown code pages into UTF-8

Under The Hood

Architecture Detection is driven by from_bytes in src/charset_normalizer/api.py, which iterates over a precomputed multibyte-first ordering of IANA codecs (IANA_SUPPORTED_MB_FIRST) so genuine CJK content short-circuits quickly. For each candidate encoding it decodes the payload in chunks via cut_sequence_chunks (utils.py), scores decoding “mess” with mess_ratio from md.py (a pipeline of MessDetector plugins), and measures linguistic coherence and language with coherence_ratio from cd.py. Signatures and BOMs are stripped through identify_sig_or_bom, and results are ranked and returned as CharsetMatches/CharsetMatch objects (models.py) exposing the chosen encoding, aliases, alternatives, chaos, and coherence.

Tech Stack Written in pure Python targeting 3.7+ with full type hints (py.typed) and from __future__ import annotations throughout. It has zero runtime dependencies. The build uses setuptools with an optional mypyc compilation hook (backend-path = ["_mypyc_hook"]) that compiles hot paths to C extensions for speed while keeping a pure-Python fallback. Large encoding tables live in constant.py.

Code Quality The repository is well tested, with 14 test modules covering base detection, coherence, legacy detect() behavior, edge cases, full detection, binary detection, large payloads, logging, and the CLI. It ships pre-commit hooks, a coverage configuration, an OSV scanner config, and a documented security policy, and carries the OpenSSF best-practices badge. Code is consistently typed and modular.

API Design The public surface is deliberately small and ergonomic: from_path('file'), then str(results.best()) gets you readable text in two lines, while from_bytes/from_fp cover in-memory and stream inputs. A chardet-compatible detect() eases migration, the normalizer CLI emits clean JSON, and extensive Read the Docs documentation covers advanced tuning such as chaos thresholds and codec isolation.

Used by 23 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,081

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
63
Dependency
Built with
Python59%
Jupyter Notebook21%
Updated 2 days ago
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,325

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
C++69%
Python13%
Updated today
C++
74%
Other

Dragonfly

Databases · Developer Tools · Devops

31,013

A modern Redis and Memcached replacement engineered for multi-core servers — delivering 25x more throughput, better cache hit rates, and up to 80% lower memory consumption with full API compatibility.

View details
90
Repo Health
9
Technical
71
Dependency
Built with
C++74%
Python16%
Updated today
Python
63%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,039

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
88
Repo Health
91
Technical
64
Dependency
Built with
Python63%
TypeScript23%
Updated 1 months ago
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,083

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
62
Repo Health
81
Technical
66
Dependency
Built with
TypeScript91%
Updated 3 days ago
HTML
48%
LGPL-2.1

Horilla

Human Resources · ERP

1,330

Open-source HRMS covering recruitment, attendance, payroll, and biometrics in one self-hosted Django application.

View details
88
Repo Health
60
Technical
65
Dependency
Built with
HTML48%
Python35%
JavaScript13%
Updated today
Python
83%
Apache 2.0

knowhere

AI Development · Developer Tools

2,515

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
83
Repo Health
75
Technical
70
Dependency
Built with
Python83%
HTML16%
Updated today

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

Search