A binary file is a file whose contents are stored in non-text, machine-readable format. Unlike plain text files, binary files contain bytes arranged in structures understood by specific programs, such as images, videos, compiled programs, or compressed archives. Because binary content may include null characters and non-printable bytes, it cannot be safely inspected with simple text tools. Programs that read binary files interpret the bytes according to predefined formats.
Why it matters
Binary files are essential for representing complex data efficiently, from photos to executables. Understanding the difference between binary and text helps prevent corruption when transferring files, editing them, or handling them in code. For example, reading a binary file incorrectly in text mode can lead to broken data or encoding issues.
Examples
Examples include JPEG images, MP4 videos, ZIP archives, or compiled application executables. Many programming lessons refer to binary formats when explaining file I/O, such as the lesson What Is a File in Coding?.