Online Notepad Tool

Guides

UTF-8, ANSI and BOM, Explained

A text file is just a sequence of bytes. Encoding is the agreement about which characters those bytes mean, and when two programs disagree about it, the result is garbled text with no error message.

What an encoding actually does

A computer never stores letters directly. It stores numbers, and an encoding is the lookup table that says which number means which character. The plain letter "A" is byte 65 in almost every encoding in common use, which is why English text without accents tends to look fine regardless of which encoding a program assumes. The trouble starts with anything outside that narrow range: an accented letter, a curly quote, an emoji, a character from a non-Latin script, since different encodings assign those to different byte sequences, or do not include them at all.

ANSI, the legacy default

"ANSI" in a Windows editor's encoding menu almost always means the system's current code page, a single-byte encoding that covers roughly 256 characters, enough for one language or a small family of related ones, but not for mixing scripts or covering the full range of accented characters used worldwide. It is a holdover from before Unicode existed, kept around because huge amounts of older software and older files still use it, not because it is a good general choice for a new file today.

UTF-8, the modern default

UTF-8 encodes every character defined in Unicode, which covers essentially every script in use, using a variable number of bytes per character: one byte for plain ASCII text, up to four for less common characters. Because its one-byte range matches ASCII exactly, a plain English UTF-8 file and a plain English ASCII file are byte-for-byte identical, which is part of why UTF-8 became the near-universal default: it costs nothing for the common case and scales to everything else. Web pages, modern source code and most software built in the last fifteen years assume UTF-8 unless told otherwise.

The Byte Order Mark, and why it causes its own problems

A BOM is a short, invisible sequence of bytes written at the very start of a file, before any actual content, whose only job is to declare which encoding the rest of the file uses. It solves a real problem: a program with no other clue can look at those first bytes and know it is reading UTF-8 rather than guessing. The problem is that plenty of tools, shell scripts, older parsers and command-line utilities among them, do not expect it and read those bytes as literal, unexpected characters glued onto the start of the file, which can break a script that looks completely correct when read by a human.

Diagnosing a garbled file

Question marks, boxes, or strings like "é" where a single accented letter should be are the classic signs of an encoding mismatch: the file's actual bytes are fine, but whatever opened it guessed the wrong encoding to interpret them with. The fix is rarely to retype the text; it is to reopen the file specifying the correct encoding, or to explicitly convert it once the right encoding is known, rather than repeatedly saving and reopening on a guess.

Handling it directly

The code editor on this site shows and lets you change both the encoding and the presence of a UTF-8 BOM from the status bar, so a file that opens garbled can be re-read with the correct encoding, and one destined for a script or config file that specifically rejects a BOM can have it removed before saving, without guessing or a separate conversion tool.

Try it: Notepad++ Online Alternative

Frequently Asked Questions

What does BOM actually stand for?
Byte Order Mark. It is a few invisible bytes written at the very start of a file to signal which encoding, and in the case of UTF-16, which byte order, the rest of the file uses. It has no visible effect in most editors, but tools that parse the raw bytes, including some command-line and configuration parsers, can choke on it.
Why do I sometimes see question marks or boxes instead of letters?
That is the visible symptom of an encoding mismatch: the program reading the file guessed a different encoding than the one it was saved in, so specific byte sequences no longer map to the characters they were meant to. Accented letters, curly quotes and non-Latin scripts are the most common victims, since plain ASCII characters look identical in most encodings anyway.
Is UTF-8 always the safe default?
For nearly everything written today, yes. It represents every character in Unicode, stays backward-compatible with plain ASCII for English text, and is the encoding almost every modern tool, browser and operating system expects by default. The main exception is a legacy system that specifically requires ANSI or another older encoding, which is worth confirming rather than assuming.
Does adding a BOM to a UTF-8 file do anything useful?
Occasionally: some older Windows software uses it to detect that a file is UTF-8 rather than the system's default ANSI codepage. But several build tools, shell scripts and parsers assume no BOM and read those extra bytes as literal, unexpected characters, which is why it causes at least as many problems as it solves and many style guides recommend leaving it off.