Open a Word document in a plain text editor and you’ll see mostly unreadable symbols, while opening a plain .txt file the same way shows normal readable words — the difference between those two experiences is exactly what separates a binary file from a text file.
Text Files
A text file stores its content using a character-encoding standard like ASCII or Unicode, where every letter, digit, and symbol maps to a specific, well-known byte pattern. Because that mapping is public and standardized, any basic text editor can open a text file and display exactly what was written, regardless of which program created it.
Binary Files
A binary file also stores nothing but 1s and 0s — every file does — but it structures those bytes according to rules specific to its format rather than a universal character map. A Word document, a photo, an executable program, and a compressed ZIP archive are all binary files, each with its own internal layout that only software built to understand that particular format can correctly interpret.
Why You Can’t Just Open Any Binary File in Notepad
Opening a binary file in a plain text editor forces the editor to apply the wrong decoding rules — it tries to read image or document data as if it were ASCII characters, which produces the wall of garbled symbols you sometimes see when a file opens incorrectly. This isn’t the file being broken; it’s simply the wrong tool being used to read it.
How to Tell Which Type You’re Dealing With
File extensions are the everyday shortcut — .txt, .csv, and .html are typically text files, while .docx, .jpg, .mp3, and .exe are binary files — but the extension is really just a hint pointing to which set of decoding rules a program should apply to that string of bytes.
How Software Recognizes a File Type
Many binary formats begin with a short, fixed signature called a magic number. Programs check these first bytes to confirm what a file really is, even if the extension was changed.
- PNG: starts with the bytes 89 50 4E 47 (the letters “PNG” after the first byte).
- JPEG: starts with FF D8 FF.
- PDF: starts with the text “%PDF”.
- ZIP: starts with 50 4B (the letters “PK”).
- GIF: starts with the text “GIF89a” or “GIF87a”.
The values here are in hexadecimal. See hexadecimal explained if you want to read them.
Looking Inside a File
A hex editor displays a file’s bytes as hexadecimal numbers alongside any readable characters. It is the usual tool for examining a binary file. You can try it with a small file you created yourself, but never edit important files without a backup, because a single changed byte can make a binary file unreadable.
Text Files Are Not Always Simple Either
Even plain text files differ slightly: line endings can be different on Windows and Unix systems, and the encoding might be ASCII or UTF-8. If a text file shows odd symbols, the encoding is usually the cause. See ASCII vs Unicode.
Why Binary Formats Exist
Binary formats are compact and fast to read for computers. A number such as 255 takes three bytes as text (“255”) but only one byte in binary. Images, audio and video would be enormous if stored as text, so they use binary layouts with compression.
Safety Notes
- Be careful with executable files (such as .exe) from unknown sources, because they can run harmful code.
- A file with a changed extension is not converted. Renaming a .png to .jpg does not change its contents.
- Keep backups before using tools that modify files.
Seeing a Text File’s Binary Side
Even a plain text file has a binary form underneath its readable surface. Our binary translator converts any typed text into its 8-bit binary representation, which is close to what a text file actually stores on disk before your text editor decodes it back into words for you. For the broader concept of what binary data covers, see our guide on what binary data actually means.
