chardet is a Python library that detects the character encoding of byte strings, providing the detected encoding, confidence score, and language. The current version is 7.4.0.post1, released on March 14, 2026. It is actively maintained with regular updates, focusing on improving accuracy and performance. The library requires Python 3.10 or higher and has zero runtime dependencies, making it suitable for various Python environments, including PyPy.
pip install chardetVerified import paths — ran on the pinned version, not inferred.
Use the 'detect' function from the 'chardet' module to analyze byte strings and determine their encoding.
Update to chardet 7.0 or later to ensure compatibility and benefit from improved performance and accuracy.
Verify that your environment is compatible with the new model format to take advantage of the performance improvements.
Install the `chardet` library using pip: `pip install chardet` (or `pip3 install chardet` for Python 3 specific installations).
Convert the string input to bytes using an appropriate encoding (e.g., `some_string.encode('utf-8')`) before passing it to `chardet.detect()`. Example: `chardet.detect(your_string.encode('utf-8'))`. If reading from a file, open it in binary read mode (`'rb'`).Ensure the input data is indeed text-like. If it's genuinely binary, `chardet` cannot detect a text encoding. If it is text, providing more data to `chardet.detect()` or using `chardet.detect_all()` to see other candidates might help.
No dependency data recorded yet.