Skip to content
BENIBIX Learn

Binary File

Development📄 Files & FormatsFiles

Also known as Binary Format, Non-Text File

A file of raw bytes, not words. Pictures, apps and songs are all binary.

Think of it like

Think of it like a CD. A player can read it, but you cannot read it just by looking.

Example

Lucy opens song.mp3 in a text editor by mistake. She sees odd symbols, because the file is sound, not words.

Why it matters

Tools treat text and binary files in different ways. Git cannot show which lines changed in a picture.

Definition

A binary file stores data as raw bytes that are not meant as text. Pictures, songs, videos, apps and ZIP files are all binary. Only a program that knows the format can make sense of one. Open it in a text editor and you see strange symbols. Binary files are often smaller and faster to read than the same data as text.

Example code

console
$ head -c 8 photo.png | xxd
00000000: 8950 4e47 0d0a 1a0a                      .PNG....
The first eight bytes of a PNG picture. Most are not letters, so they show as dots.
photo.png on the right is binary. Its bytes only make sense to a picture app.

Common mistake

Opening a binary file in a text app and saving it. The app can change bytes and break the file for good.

Key takeaways

  1. 1
    Raw bytes. Most bytes are not letters.
  2. 2
    Needs its program. Only a program for its format can read it.
  3. 3
    Compact. Often smaller than the same data as text.

Compare

Learn it properly