1. License
“to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software”
MIT allows use in paid and closed-source products.
github.com/jawah/charset_normalizer/blob/master/LICENSE3. Used by agents' projects
Dependency in 67 public GitHub projects set up for AI coding agents that we scanned (1.1%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error
What charset-normalizer does
charset-normalizer is a free Python library for text files whose character set nobody told you. It looks at the raw bytes and works out how to turn them into readable text. It also names the likely language and spots files that are not text at all. On short snippets its guess can be wrong, so known character sets should still come first.
What people build with it
Open uploads in any old encoding
People upload subtitles, price lists or exports from old programs; your app turns each file into readable text without asking which character set it uses.
Narrow the guess when you know a shortlist
Your users are mostly in Western Europe, so you let it choose only between Windows-1252 and UTF-8 and avoid look-alike character sets.
Swap out chardet in old code
An older script uses chardet to guess file encodings; you change one import line and keep everything else.
Turn away files that are not text
A text import form rejects pictures or archives renamed to .txt before your code tries to read them.
Check a folder of files from the terminal
Before an import, you run one command on old files and see the likely character set and language of each.
Read scraped pages with no declared charset Idea
A scraper meets pages that do not say which character set they use and still saves readable text from them.
charset-normalizer popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How charset-normalizer is used
- charset-normalizer is a dependency in 67 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (4.1% of the 1,623 Python ones), #19 of 408 in utilities.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,375; those are left out of every share on this page.
- Projects that use it most often also use Requests (94.0%), urllib3 (91.0%), Click (76.1%).
By coding agent
Often used with
More about charset-normalizer
Funding
- GitHub Sponsors: https://github.com/Ousret
- Tidelift: https://tidelift.com/funding/github/pypi/charset-normalizer
- 1 GitHub sponsors
Alternatives
charset-normalizer This page
Pick ftfy when the text was already decoded wrongly and shows broken symbols; the charset-normalizer README says ftfy repairs such text while it converts raw bytes.
Pick jschardet when you need the same kind of guess in JavaScript rather than Python.
Pick iconv-lite when you already know the character set and need to convert text in JavaScript.
Get started
Tell your AI assistant
“Use the Python package charset-normalizer (pin charset-normalizer==3.5.2) to decode uploaded text files whose encoding is unknown; use a declared charset or BOM first, call from_bytes(raw).best(), handle None, and limit cp_isolation to the encodings your users really have.”
Install it into your project's Python environment.
pip install charset-normalizer -UFrom github.com/jawah/charset_normalizer/blob/master/README.md
Pass raw bytes or a file path and take the best match; str() gives the decoded text.
from charset_normalizer import from_bytes, from_path # This is going to print out your sequence once properly decoded print(str(from_bytes(my_byte_str).best())) # You could also want the same from a file print(str(from_path('./data/sample.1.ar.srt').best()))From charset-normalizer.readthedocs.io/en/latest/user/getstarted.html
Mistakes to avoid
In our run a one-line French cp1252 text came back as cp1250 with à turned into ŕ; three lines or a shortlist fixed it.
best() returns None when nothing fits, and str(None) would quietly give the text 'None'.
A cut-off multi-byte character makes the guess fail; the docs say the package is fast enough without cutting.
output() drops characters the target cannot hold, without replacing them or warning you.
-r replaces files and -f skips the question, so a wrong guess overwrites the only copy.
Questions
Can I use it in a paid, closed-source app?
Yes. It is MIT licensed; keep the copyright and license notice with the package.
Is it a drop-in replacement for chardet?
Mostly. It offers the same detect() function, and the docs say switching the import is usually enough.
Can it repair text that already shows broken symbols?
No. It works on raw bytes. For text that was already decoded wrongly, the README points to ftfy.
Can I feed it only the first part of a big file to save time?
Better not. A cut-off multi-byte character can make it fail, and the docs say it is fast enough on whole files.
Is it maintained?
Yes. Version 3.5.2 was uploaded to PyPI on 30 September 2026.