Binary file
Adapted from Wikipedia · Adventurer experience
A binary file is a type of computer file that is different from a text file. Text files have letters, numbers, and symbols we can read right away. Binary files use special code that computers understand. These files often hold things we can’t see as simple text, like pictures or music.
Many binary file formats have some text mixed in with their data. For example, some older computer document files, such as older Microsoft Word document files, store the words of a document as text. They also have extra parts in binary form that tell the computer how the text should look — like bold or underlined words.
Binary files are important because they let computers store and work with many kinds of information that text alone can’t handle. Whether it’s a photo, a video, or a program, these files help computers process and show data in many useful ways.
Background and terminology
All modern computers store information using tiny units called bits (binary digits), following a system known as binary code. Because of this, every piece of data on a computer can be thought of as "binary."
One common type of file contains text, which is made possible through a special system called a character encoding. These are known as "text files." Files that are not like this are called "binary files."
Sometimes, "text files" might include parts that are actually binary data, and many "binary files" have parts that look like text. These mixed files are usually treated as "binary" because a program that only understands text wouldn’t know how to handle them properly.
Structure
Binary files are groups of numbers called bytes. These bytes are made from eight bits, the smallest pieces of digital information. Binary files are not for reading like a book. They store things such as pictures, sounds, or programs that your computer can use.
Some binary files have special parts called headers that help the computer know what is inside. For example, a picture file might start with a code like GIF87a to show that it is a GIF image. If a file does not have these special parts, it might be called a flat binary file. Sometimes, binary files need to be changed so they can travel over the internet safely, using codes like Base64.
Manipulation
Sometimes, we need to send binary files through systems like email that can't handle all types of data. To do this, the file is changed into plain text using methods like Base64. This makes the file a bit bigger—about 30% larger—but it can be turned back into the original file after it is received.
Both Microsoft Windows and Unix-like systems let programmers choose if a file is plain text or a binary file when they open it. This choice helps the system handle special characters correctly.
Viewing
You can use a special tool called a hex editor to look at a binary file. This tool shows the file’s data as numbers or characters.
If you try to open a binary file with a regular text editor, it will look messy and hard to read. Some programs can show just the readable text from a binary file.
Interpretation
Standards help us understand binary files. For example, a binary file might look like text in one program, but another program can see it as sounds or pictures. Binary data only means something when a program decides what each part is. Just looking at the binary might not tell you what it really is.
This idea is used in steganography, where a program can see a file in a new way to find hidden messages. Without the special program, you can't even know those hidden messages are there.
Binary compatibility
For binary code executable file compatibility, see Binary compatible.
Two files that work well together will have the same pattern of zeros and ones in the main part of the file. But, the beginning part of the file, called the header, might look different.
This idea is often used to explain how data files from one program can be the same as files from another program. For example, some companies make programs for both Windows and the Macintosh that work well together. This means a file made on a Windows computer can be used on a Macintosh computer without any problems. This helps avoid issues that happen when moving data between different programs.
One possible problem is how computers arrange the bytes in a file. Some computers store these bytes in a different order.
Related articles
This article is a child-friendly adaptation of the Wikipedia article on Binary file, available under CC BY-SA 4.0.
Safekipedia