Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

charset-normalizer

Read text files of unknown encoding.

UtilitiesPYPI

GitHub

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/LICENSE

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

68 / 100
Gid Score, #509 overall
357M
downloads a week, pypi
810
GitHub stars
67
agent projects use it
charset-normalizer: downloads per weekPyPI, charset-normalizer 350,339,790
charset-normalizer: GitHub starsjawah/charset_normalizer 810

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

41 projects, 1.4%
37 projects, 1.1%
25 projects, 1.0%

Often used with

In 94.0% of its projects
In 91.0% of its projects
In 76.1% of its projects
In 76.1% of its projects

More about charset-normalizer

Funding
  • GitHub Sponsors: https://github.com/Ousret
  • Tidelift: https://tidelift.com/funding/github/pypi/charset-normalizer
  • 1 GitHub sponsors

See all

More in Utilities

Alternatives

charset-normalizer This page

MITGid 68357M/wk

ftfy

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.

jschardet

Pick jschardet when you need the same kind of guess in JavaScript rather than Python.

iconv-lite

Pick iconv-lite when you already know the character set and need to convert text in JavaScript.

Compare charset-normalizer with another tool

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.”

  1. Install it into your project's Python environment.

    pip install charset-normalizer -U

    From github.com/jawah/charset_normalizer/blob/master/README.md

  2. 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

Trusting from_bytes(raw).best() on a short line of text without checks
Use the declared charset when there is one, pass cp_isolation with the sets your users really have, or detect on more text

In our run a one-line French cp1252 text came back as cp1250 with à turned into ŕ; three lines or a shortlist fixed it.

str(from_bytes(raw).best()) without checking the result
best = from_bytes(raw).best(); if best is None, reject the file or fall back to a known encoding

best() returns None when nothing fits, and str(None) would quietly give the text 'None'.

Detecting on the first 1,000 bytes of a large file to save time
Pass the whole content (or a cut that ends on a full line) to from_bytes

A cut-off multi-byte character makes the guess fail; the docs say the package is fast enough without cutting.

best.output('cp1252') to save text back into a legacy encoding
Keep the result as UTF-8 (the default of output()), or encode yourself with errors='strict' and handle failures

output() drops characters the target cannot hold, without replacing them or warning you.

Running the normalizer command with -r -f on a folder of originals
Run it with -n first (writes new files) and keep the originals until you have checked them

-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.