Version 4.0.0 (RC0)
Pre-release
Pre-release
jschardet 4 is a ground-up TypeScript port of chardet 7. It's much faster and more accurate than jschardet 3, and a drop-in replacement for its documented API. Ships IIFE and ESM bundles in dist/ plus the CLI.
Comparison
99.2% accuracy on 2,517 test files, up from 42.0% in jschardet 3, with ~6× the throughput and ~9× lower peak memory. Language detection for every result. MIME type detection for binary files.
| jschardet 4.0.0 | jschardet 3.1.4 | chardet 7.4.3 (Python) | |
|---|---|---|---|
| Accuracy (2,517 files) | 99.2% | 42.0% | 99.2% |
| Speed | 945 files/s | 154 files/s | 187 files/s |
| Language detection | 97.4% | — | 97.4% |
| Peak memory | 84.5 MiB | 751.4 MiB | 50.7 MiB |
| Bundle size (min / gzip) | 1,043 / 676 KiB | 334 / 120 KiB | — |
| Cold start (import + first detect) | 80.3 ms | 25.7 ms | 94.9 ms |
| Runs in browsers | yes | yes | — |
| MIME type detection | yes | no | yes |
| License | 0BSD | LGPL | 0BSD |
Compared to jschardet 3, v4 has a larger bundle and a ~80 ms first-call cost. Both come from shipping a larger detection model; the model decompresses once on first detect() and stays in memory afterwards, so subsequent calls run at full speed.