Character Encoding Detection for Files and Bytes – Free

Find out how a file is encoded before you parse it. This character encoding detection tool looks for a Unicode byte-order mark and checks whether the bytes are valid UTF-8, without uploading the file.

How to use the Character Encoding Detection tool

  1. Choose a file of up to 20 MiB under File (optional), or leave it empty and paste bytes into Hex bytes if no file is selected.
  2. Write hex as pairs such as EF BB BF 48 69. Spaces, commas, line breaks and 0x prefixes are allowed.
  3. Select Inspect. The Example button loads a five-byte sample that starts with a UTF-8 byte-order mark.
  4. Read the one-line verdict in the Result box and select Copy if you want to keep it.

How this character encoding detection works

A byte-order mark, or BOM, is the code point U+FEFF written at the very start of a text stream. Each Unicode encoding form stores it as a different byte pattern, so the first two to four bytes of a file can identify the encoding. The tool compares them with the five patterns below.

If there is no BOM, the tool runs the whole input through a strict UTF-8 decoder. UTF-8 has a tight structure of lead and continuation bytes. Text in a legacy single-byte encoding that contains accented letters almost never satisfies it by accident, so passing the check is strong evidence of UTF-8.

  • EF BB BF: UTF-8
  • FE FF: UTF-16, big-endian
  • FF FE: UTF-16, little-endian
  • 00 00 FE FF: UTF-32, big-endian
  • FF FE 00 00: UTF-32, little-endian

Reading the result

The tool reports exactly one of four outcomes. The samples below show the precise wording of each.

  • An encoding name followed by byte-order mark found. The tool stops at the BOM and does not validate the bytes after it.
  • ASCII-compatible bytes, also valid UTF-8. Every byte is below 80 hex, so the data reads the same in ASCII, UTF-8 and Windows-1252.
  • Valid UTF-8, no byte-order mark. At least one multi-byte sequence is present and all of them are well formed.
  • No Unicode byte-order mark and invalid UTF-8. The data is binary or uses a legacy encoding such as Windows-1252 or Shift_JIS. The tool does not guess which.
EF BB BF 48 69  →  UTF-8 · byte-order mark found
48 69           →  ASCII-compatible bytes · also valid UTF-8
C3 A9           →  Valid UTF-8 · no byte-order mark
E9              →  No Unicode byte-order mark and invalid UTF-8. The remaining encoding is undetermined.

Limits you should know about

This is a deterministic check, not a statistical guesser. It never names Windows-1252, ISO-8859-1, Shift_JIS or any other legacy code page, because those cannot be proven from the bytes alone.

Three edge cases are worth knowing. UTF-16 text without a BOM is not recognized, and basic Latin text in that form still passes as ASCII-compatible because of its zero bytes. A UTF-16 little-endian file whose first character is U+0000 starts with FF FE 00 00 and is reported as UTF-32. An empty file is reported as ASCII-compatible.

A selected file takes priority over the hex box, and a file above 20 MiB is refused.

Why the byte-order mark matters in practice

A stray UTF-8 BOM is a common cause of bugs: a JSON parser that rejects the first character, a CSV whose first column name has three invisible bytes in front of it, or a script whose shebang line is not recognized. In the other direction, a spreadsheet program may misread a UTF-8 CSV unless the file begins with a BOM.

Frequently asked questions

What is a byte-order mark?

It is the Unicode character U+FEFF placed at the start of a file. In UTF-16 and UTF-32 it shows whether the bytes are big-endian or little-endian. In UTF-8 it has no byte-order meaning and only acts as a signature, written as EF BB BF.

Can this tool detect Windows-1252 or ISO-8859-1?

No. It confirms Unicode encodings through a byte-order mark and confirms UTF-8 through validation. For anything else it says the encoding is undetermined, because single-byte code pages accept almost any byte sequence and cannot be told apart reliably.

Is my file uploaded for inspection?

No. The browser reads the file into memory and the check runs in the page. The file content is not sent anywhere, and the tool only prints a one-line verdict.

Should I save UTF-8 files with or without a BOM?

Without, in most cases. The Unicode standard permits a UTF-8 BOM but does not recommend it, and many parsers and Unix tools treat it as unexpected data. Keep it only when a consumer such as a spreadsheet program needs it.

Related tools