DevTools Logo

Charset Detector

Charset Detector

Find the encoding of pasted text or a file, compare decodes and repair mojibake locally.

Runs in your browser
Try an example

Bytes to inspect

Detection report

No bytes to inspect yet

Paste text or load a sample file to see ranked encodings.

The Charset Detector works directly on bytes. Paste text (encoded as UTF-8) or upload a file up to 5 MB and the tool checks BOMs, validates UTF-8 strictly, measures UTF-16 null-byte density, scores Windows-1252 and Latin-1 candidates, and reports CJK byte-pattern hints. Each candidate shows a confidence percentage, concrete evidence and a decoded preview; clicking one changes the decoded text pane. Byte statistics include high-byte counts, null bytes and mixed line endings. When a decode shows double-encoded mojibake markers such as é, a one-click repair reinterprets the characters as UTF-8. Nothing is uploaded.

Curly quote in cp1252

bytes 49 74 92 73 → It’s

Byte 0x92 is undefined in UTF-8 but maps to a right single quote in Windows-1252.

UTF-8 BOM

EF BB BF 41 → A (UTF-8, BOM found)

A byte-order mark pins the encoding before any statistical scoring.

Mojibake repair

é → é

Reinterpreting double-encoded characters as UTF-8 removes the garbled markers.

Examples

Curly apostrophe

Input
49 74 92 73
Output
It’s (Windows-1252)

Byte 0x92 has no UTF-8 meaning but is a right single quote in cp1252.

UTF-8 BOM

Input
EF BB BF 41
Output
A — UTF-8, BOM found

The BOM identifies the encoding before any statistical scoring.

Double-encoded é

Input
é
Output
é after repair

The repair loop reinterprets mojibake markers as UTF-8 bytes.

About this tool

A text file is bytes, not characters. If a file written in Windows-1252 is opened as UTF-8 — or UTF-16 is read as Latin-1 — the result is garbled text known as mojibake. This detector inspects the bytes directly: it checks byte-order marks, walks UTF-8 sequences strictly, measures null-byte density at odd and even offsets, and scores Windows-1252 and Latin-1 using the bytes actually present.

Every candidate is shown with a confidence score and concrete evidence: a BOM, the first invalid UTF-8 offset, a byte undefined in cp1252, or the frequency of high bytes. Clicking a candidate decodes the same bytes with that charset and shows a preview, a replacement-character count and the decoded text pane. A CJK lead-byte pattern is reported as a hint rather than a confident identification, because SJIS, Big5 and EUC cannot be distinguished reliably from a short sample.

When the decode contains classic double-encoding markers such as é or ’, the tool offers a one-click repair that reinterprets those characters as UTF-8 bytes. Byte statistics and line-ending counts help diagnose file-format problems. Files are capped at 5 MB and everything is analyzed in your browser — the bytes never leave your device.

What this tool does not do

  • Heuristic scoring can be wrong for short or unusual files; the preview is the final check.
  • CJK lead-byte patterns produce a hint only; SJIS, Big5 and EUC decoders are not bundled.
  • Files over 5 MB are rejected; the tool analyzes bytes in memory rather than streaming them.

How to use this tool

  1. Provide bytes

    Paste text to measure it as UTF-8 bytes, or upload a file (up to 5 MB) to inspect its raw bytes.

  2. Read the ranked candidates

    The table lists encodings with confidence percentages and evidence such as BOMs, invalid UTF-8 offsets or cp1252-specific bytes.

  3. Compare decodes

    Click an encoding name to decode the same bytes with that charset and inspect the preview and replacement-character count.

  4. Repair mojibake

    If the decoded text shows markers such as é, use Apply mojibake repair to reinterpret the characters as UTF-8.

  5. Copy or download

    Copy the decoded text or download it as a UTF-8 .txt file; byte and line-ending statistics remain visible below the report.

Use cases

Opening a legacy export

Identify whether a CSV from an old system is cp1252 or Latin-1 before importing it into a modern toolchain.

Debugging garbled text

Find the exact byte that breaks a UTF-8 decode and see which charset produces readable text.

Auditing file hygiene

Check BOM presence, null-byte density and mixed CRLF/LF line endings in a downloaded dataset.

Evidence used for detection

SignalWhat it means
EF BB BF / FF FE / FE FFUTF-8 / UTF-16LE / UTF-16BE byte-order mark — near-certain identification
Strict UTF-8 walkA clean multibyte walk makes UTF-8 a strong candidate; first invalid offset is reported
Null density at odd/even offsetsHigh odd-offset density suggests UTF-16LE; even-offset density suggests UTF-16BE
Bytes 0x81, 0x8D, 0x8F, 0x90, 0x9DUndefined in Windows-1252 — penalizes that candidate
Byte 0x92Maps to a curly apostrophe in cp1252 — positive evidence for that encoding
CJK lead-byte patternsHint only: SJIS/Big5/EUC cannot be distinguished from a short sample
à / †markersSignals double-encoded text that may be repairable

Confidence is a heuristic score, not a guarantee — always sanity-check the decoded preview.

Common mistakes

Mistake:Assuming valid UTF-8 means the text is correct.

Fix:Check the preview. Double-encoded text is valid UTF-8 too; look for à or †markers and use the repair action.

Mistake:Trusting a CJK pattern hint as a decoder.

Fix:SJIS, Big5 and EUC share lead-byte ranges. The tool labels CJK detection as a hint because a confident guess would be misleading.

Mistake:Treating replacement characters as part of the original file.

Fix:U+FFFD means the chosen charset could not decode a sequence. Try another candidate before copying or saving the text.

Frequently asked questions

How does the tool detect a file's charset?

It inspects the bytes in order. A byte-order mark is decisive when present; otherwise it performs a strict UTF-8 validation, measures how often null bytes appear at odd versus even offsets (the UTF-16 signal), and scores Windows-1252 and Latin-1 using high-byte ratios, undefined bytes and known mappings such as 0x92 for a curly apostrophe. Candidates are ranked with their evidence so you can judge the result rather than trust a single answer.

What is mojibake and why does it happen?

Mojibake is garbled text produced when bytes are decoded with the wrong charset — for example, Windows-1252 bytes for é (C3 A9) read as Latin-1 produce é. Double-encoded text happens when already-garbled characters are saved again as UTF-8. The detector flags the characteristic à and †markers and offers a repair that reinterprets those characters as UTF-8 bytes.

Can I upload a file instead of pasting text?

Yes. File upload reads the raw bytes, which is the honest way to detect an unknown encoding — pasted text has already been decoded as UTF-8 by the browser. Files are limited to 5 MB and are processed entirely in your browser; nothing is transmitted.

Why isn't Shift-JIS or Big5 decoded automatically?

Those encodings share lead-byte ranges with other CJK charsets, so a short sample cannot identify them reliably. The tool reports a CJK pattern hint with supporting evidence instead of pretending to know. For a confident result you need encoding metadata from the source system or a larger sample with a dedicated CJK decoder.

What does a replacement character (U+FFFD) in the preview mean?

It means the selected charset could not decode a byte or sequence. Try another candidate from the table — a Windows-1252 file opened as UTF-8 will show replacement characters, while the cp1252 decode should read normally. Replacement counts are displayed for each candidate so you can compare them.

Why do line endings appear in the report?

CRLF, LF and bare CR counts help diagnose files from mixed systems and explain why a downstream parser might split lines differently. The report counts each form separately, including mixed files, without normalizing the bytes.

References & standards