{
 "kind": "tool",
 "slug": "charset-normalizer",
 "path": "tools/charset-normalizer/",
 "name": "charset-normalizer",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Utilities",
   "tools/utilities/"
  ]
 ],
 "lead": "Read text files of unknown encoding.",
 "chips": [
  {
   "label": "Utilities",
   "path": "tools/utilities/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install charset-normalizer"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/jawah/charset_normalizer"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "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",
   "note": "MIT allows use in paid and closed-source products.",
   "src": "https://github.com/jawah/charset_normalizer/blob/master/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 23, 2026",
   "note": "Latest GitHub release Nov 23, 2026. ",
   "src": "https://github.com/jawah/charset_normalizer"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "67 projects",
   "status": "info",
   "sub": "#19 of 408 in its category",
   "note": "Dependency in 67 public GitHub projects set up for AI coding agents that we scanned (1.1%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What charset-normalizer does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Open uploads in any old encoding",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Narrow the guess when you know a shortlist",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Swap out chardet in old code",
       "text": "An older script uses chardet to guess file encodings; you change one import line and keep everything else.",
       "idea": false
      },
      {
       "title": "Turn away files that are not text",
       "text": "A text import form rejects pictures or archives renamed to .txt before your code tries to read them.",
       "idea": false
      },
      {
       "title": "Check a folder of files from the terminal",
       "text": "Before an import, you run one command on old files and see the likely character set and language of each.",
       "idea": false
      },
      {
       "title": "Read scraped pages with no declared charset",
       "text": "A scraper meets pages that do not say which character set they use and still saves readable text from them.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "charset-normalizer popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "68",
       "of": "/ 100",
       "l": "Gid Score, #509 overall"
      },
      {
       "n": "357M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "810",
       "l": "GitHub stars"
      },
      {
       "n": "67",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How charset-normalizer is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "41 projects, 1.4%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "37 projects, 1.1%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "25 projects, 1.0%",
       "v": "Cursor",
       "path": "agents/cursor/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 94.0% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 91.0% of its projects",
       "v": "urllib3",
       "path": "tools/urllib3/"
      },
      {
       "l": "In 76.1% of its projects",
       "v": "Click",
       "path": "tools/click-py/"
      },
      {
       "l": "In 76.1% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about charset-normalizer",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/Ousret",
        "Tidelift: https://tidelift.com/funding/github/pypi/charset-normalizer",
        "1 GitHub sponsors"
       ]
      },
      {
       "title": "More in Utilities",
       "path": "tools/utilities/",
       "items": [
        {
         "text": "clsx",
         "path": "tools/clsx/"
        },
        {
         "text": "date-fns",
         "path": "tools/date-fns/"
        },
        {
         "text": "PyYAML",
         "path": "tools/pyyaml/"
        },
        {
         "text": "uuid",
         "path": "tools/uuid/"
        },
        {
         "text": "yaml",
         "path": "tools/yaml/"
        },
        {
         "text": "js-yaml",
         "path": "tools/js-yaml/"
        },
        {
         "text": "glob",
         "path": "tools/glob/"
        },
        {
         "text": "Lodash",
         "path": "tools/lodash/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "charset-normalizer",
       "me": true,
       "facts": [
        "MIT",
        "Gid 68",
        "357M/wk"
       ]
      },
      {
       "name": "ftfy",
       "why": "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.",
       "path": "tools/ftfy/",
       "facts": []
      },
      {
       "name": "jschardet",
       "why": "Pick jschardet when you need the same kind of guess in JavaScript rather than Python.",
       "path": "tools/jschardet/",
       "facts": []
      },
      {
       "name": "iconv-lite",
       "why": "Pick iconv-lite when you already know the character set and need to convert text in JavaScript.",
       "path": "tools/iconv-lite/",
       "facts": []
      }
     ],
     "more": "Compare charset-normalizer with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "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."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Install it into your project's Python environment.",
       "code": "pip install charset-normalizer -U",
       "src": "https://github.com/jawah/charset_normalizer/blob/master/README.md"
      },
      {
       "text": "Pass raw bytes or a file path and take the best match; str() gives the decoded text.",
       "code": "from charset_normalizer import from_bytes, from_path\n# This is going to print out your sequence once properly decoded\nprint(str(from_bytes(my_byte_str).best()))\n# You could also want the same from a file\nprint(str(from_path('./data/sample.1.ar.srt').best()))\n",
       "src": "https://charset-normalizer.readthedocs.io/en/latest/user/getstarted.html"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "Trusting from_bytes(raw).best() on a short line of text without checks",
       "fix": "Use the declared charset when there is one, pass cp_isolation with the sets your users really have, or detect on more text",
       "why": "In our run a one-line French cp1252 text came back as cp1250 with à turned into ŕ; three lines or a shortlist fixed it."
      },
      {
       "dont": "str(from_bytes(raw).best()) without checking the result",
       "fix": "best = from_bytes(raw).best(); if best is None, reject the file or fall back to a known encoding",
       "why": "best() returns None when nothing fits, and str(None) would quietly give the text 'None'."
      },
      {
       "dont": "Detecting on the first 1,000 bytes of a large file to save time",
       "fix": "Pass the whole content (or a cut that ends on a full line) to from_bytes",
       "why": "A cut-off multi-byte character makes the guess fail; the docs say the package is fast enough without cutting."
      },
      {
       "dont": "best.output('cp1252') to save text back into a legacy encoding",
       "fix": "Keep the result as UTF-8 (the default of output()), or encode yourself with errors='strict' and handle failures",
       "why": "output() drops characters the target cannot hold, without replacing them or warning you."
      },
      {
       "dont": "Running the normalizer command with -r -f on a folder of originals",
       "fix": "Run it with -n first (writes new files) and keep the originals until you have checked them",
       "why": "-r replaces files and -f skips the question, so a wrong guess overwrites the only copy."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Can I use it in a paid, closed-source app?",
       "a": "Yes. It is MIT licensed; keep the copyright and license notice with the package.",
       "evidence": {
        "url": "https://github.com/jawah/charset_normalizer/blob/master/LICENSE",
        "quote": "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software."
       }
      },
      {
       "q": "Is it a drop-in replacement for chardet?",
       "a": "Mostly. It offers the same detect() function, and the docs say switching the import is usually enough.",
       "evidence": {
        "url": "https://charset-normalizer.readthedocs.io/en/latest/user/getstarted.html",
        "quote": "This function is mostly backward-compatible with Chardet."
       }
      },
      {
       "q": "Can it repair text that already shows broken symbols?",
       "a": "No. It works on raw bytes. For text that was already decoded wrongly, the README points to ftfy.",
       "evidence": {
        "url": "https://github.com/jawah/charset_normalizer/blob/master/README.md",
        "quote": "ftfy goal is to repair Unicode string whereas charset-normalizer to convert raw file in unknown encoding to unicode."
       }
      },
      {
       "q": "Can I feed it only the first part of a big file to save time?",
       "a": "Better not. A cut-off multi-byte character can make it fail, and the docs say it is fast enough on whole files.",
       "evidence": {
        "url": "https://charset-normalizer.readthedocs.io/en/latest/user/support.html",
        "quote": "If you feed an incomplete byte sequence (eg. truncated multi-byte sequence) the detector will most likely fail to return a proper result."
       }
      },
      {
       "q": "Is it maintained?",
       "a": "Yes. Version 3.5.2 was uploaded to PyPI on 30 September 2026.",
       "evidence": {
        "url": "https://pypi.org/pypi/charset-normalizer/3.5.2/json",
        "quote": "\"upload_time\":\"2026-09-30T04:34:42\""
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi charset-normalizer"
  ],
  [
   "Category",
   "Utilities"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Gid Score",
   "67.6"
  ],
  [
   "Rank in category",
   "#19 of 408"
  ],
  [
   "GitHub",
   "jawah/charset_normalizer"
  ],
  [
   "Last change",
   "Nov 23, 2026"
  ]
 ],
 "good": [
  "It does not try to find the exact original character set, only one that gives the same readable text; Shift_JIS may come back as cp932.",
  "Guesses need enough text. On a few words it can pick a look-alike set; in our run a short French line came back with one wrong letter.",
  "Its docs call detection a last resort; if the file, page or header states its character set, use that."
 ],
 "checked_line": "Read by AgentGid from 11 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/jawah.png"
}