A binary file stores data as sequences of 1s and 0s that a computer reads directly

A binary file is any file your computer reads as raw numbers — ones and zeros — rather than as text you can see on screen. When you open a Word document, an image, a video, or an audio file, your computer is reading binary data and translating it into something human-readable or playable. The file itself is just a long string of binary digits (bits), grouped into bytes, that mean different things depending on what program opens it.

The opposite is a text file, which stores information as characters — letters, numbers, punctuation — that you can read directly in any text editor. A .txt file is text. A .jpg image file is binary. A .docx Word document is actually binary, even though it contains text, because the file also stores formatting, fonts, and layout as binary code.

The distinction matters because binary files are compact, fast for computers to process, and can store complex information like images and sound. Text files are human-readable and portable across different systems, but they take up more space and cannot store things like color or audio without special encoding.

Key Takeaways

  • Binary files store data as 1s and 0s that computers read directly, while text files store readable characters like letters and numbers.
  • Common binary file types include images (.jpg, .png), videos (.mp4, .mov), audio (.mp3, .wav), and documents with formatting (.docx, .pdf).
  • Binary files are smaller and faster for computers to process, but you cannot read them in a text editor without the right program.
  • The file extension (.jpg, .mp3, .exe) tells your computer which program should open the file and how to interpret the binary data inside.

How binary files differ from text files

When you save a text file as .txt, every character — the letter A, the number 5, a space — is stored as a specific binary code. You can open that file in Notepad, Word, or any text editor and read it immediately. The binary code translates directly to visible characters.

A binary file does not work that way. The 1s and 0s inside represent something else entirely — pixel colors in an image, sound wave frequencies in an audio file, or formatting instructions in a document. If you try to open a .jpg image file in Notepad, you will see garbage characters because Notepad is trying to translate image data as if it were text. The data is not corrupted; the program is just reading it wrong.

This is why file extensions matter. The .jpg extension tells your computer "this is a JPEG image — use an image viewer or editor." The .mp3 extension says "this is audio — use a media player." Without the correct program, the binary data is unreadable to humans.

Common binary file types and what they contain

Most files you use daily are binary. Images (.jpg, .png, .gif, .bmp) store pixel data — the color and brightness of each dot on screen. Videos (.mp4, .mov, .avi) store compressed video frames plus audio tracks. Audio files (.mp3, .wav, .flac) store sound wave information. All of these are binary because they need to be compact and because computers need to process them quickly.

Documents with formatting are also binary. A .docx file (Microsoft Word) contains not just text but also font names, sizes, colors, margins, and images — all encoded as binary data. A .pdf file is binary for the same reason: it stores text, layout, fonts, and sometimes images in a format that looks identical on any device. A plain .txt file, by contrast, is text — it stores only characters, no formatting.

Executable files (.exe on Windows, .app on Mac) are binary. They contain machine code — instructions your processor understands directly. You cannot read them as text because they are not meant for humans to read; they are meant for the CPU to execute.

Why computers use binary format

Binary is the only language computers truly understand. At the hardware level, every transistor in your processor is either on or off — 1 or 0. Everything your computer does, from displaying this webpage to playing music, ultimately comes down to billions of these on-off switches flipping in sequence.

Binary files are also efficient. A .jpg image file is much smaller than the same image stored as text would be, because binary encoding is denser. A video file in .mp4 format uses compression algorithms that work on binary data to shrink the file without losing much quality. Text files cannot compress the same way because they must remain readable as characters.

Speed is another reason. When your computer opens a .mp3 file, it reads the binary data directly into memory and sends it to your audio hardware. There is no translation step. With a text file, the computer has to decode each character, which takes slightly longer — not noticeable for small files, but it adds up.

How to tell if a file is binary or text

The easiest way is to look at the file extension. Extensions like .txt, .csv, .html, and .xml are text. Extensions like .jpg, .mp3, .mp4, .exe, .docx, and .pdf are binary. If you are unsure, try opening the file in a text editor like Notepad (Windows) or TextEdit (Mac). If you see readable text, it is a text file. If you see random characters or symbols, it is binary.

On Mac, you can also right-click a file, select "Get Info," and look at the "Kind" field. On Windows, right-click and select "Properties" to see the file type. Some files will say "Text Document" and others will say "JPEG Image" or "MP3 Audio File."

Another method is to check the file size. A binary file containing an image or video is usually much smaller than a text file containing the same amount of information would be, because binary encoding is more efficient.

Why you cannot edit binary files like text

You technically can open a binary file in a text editor, but the result is meaningless. The binary data inside represents colors, sounds, or machine instructions — not characters. When the text editor tries to display this data as text, it shows garbage because it is translating numbers that were never meant to be characters.

If you edit and save a binary file in a text editor, you corrupt it. The program that is supposed to open it (an image viewer, media player, or word processor) will no longer understand the data inside. The file becomes unreadable.

To edit binary files, you need the correct program. To edit a .jpg image, use Photoshop, GIMP, or another image editor. To edit a .docx document, use Word or a compatible word processor. These programs understand the binary format and can read, modify, and save the data correctly.

Text files that look like they might be binary

Some text files have confusing names. A .csv file (comma-separated values) is text — it stores data in rows and columns, separated by commas, and you can open it in Notepad or Excel. A .json file is text — it stores structured data in a human-readable format. A .html file is text — it contains the code that makes a webpage, and you can read it in any text editor.

These files have special purposes and special formats, but they are still text underneath. You can open them in Notepad and see readable content. A .jpg file, by contrast, will show only garbage in Notepad because it is truly binary.

Frequently Asked Questions

Can I convert a binary file to a text file?

Not directly. A binary file contains data that is not meant to be text — like image pixels or audio waves. You would need to use a program designed for that file type to export or save the data in a text-readable format. For example, you can export an image as text by converting it to .csv or .json, but the result is not the image itself; it is a description of the image data.

What happens if I change a file extension?

Changing the extension does not change what is inside the file. If you rename a .jpg file to .txt, the binary image data is still there — it just tells your computer to try opening it as text, which will fail or show garbage. The file is not corrupted; you just told your computer to read it the wrong way. Rename it back to .jpg and it works again.

Why are some programs unable to open binary files?

Because the program does not understand that particular binary format. A text editor cannot read a .jpg because it does not have the code to translate image binary data into pixels. A media player cannot read a .docx file because it does not understand Word's binary format. You need a program designed for that specific file type.

Is binary format more secure than text format?

Not inherently. Binary files are harder for humans to read at a glance, but they are not encrypted or protected. A hacker or malware can still read and modify binary files if they have access to your computer. Security comes from encryption, passwords, and file permissions — not from whether a file is binary or text.

Do all images have to be binary?

Most practical images are binary because binary formats like .jpg and .png are compact and efficient. You can store image data as text in formats like .svg (scalable vector graphics), which is actually text-based XML code that describes shapes and colors. But for photographs and complex images, binary formats are standard because they are much smaller and faster to display.