A binary file is any file stored on a computer or related media. Any and all computer data is stored in binary form — that is, it consists of ones and zeros. Computer files that have only textual information are simpler than other files, such as those that store images, for instance. Therefore, a distinction is often made between text files and all other file types, and the term "binary file" typically refers to the latter.
Computer data is often broken up into characters, and each is called a byte of information. The word “Hi” is broken up into two characters — “H” and “i” — which can be represented as numbers 72 and 105. These numbers are then stored in a computer file in binary form as 01001000 and 01101001.
Text files may contain textual characters such as H, i, period, space, symbols, as well as information such as tab placement and start of a new line. Formatting information can be coded in a text file, for example, <b> indicates bold in web page HTML files. Computers manipulate data beyond this, however, and data could be normal numbers, big scientific numbers, images, sounds, videos, program instructions, etc. Such data cannot be stored efficiently in text files, and is stored in binary instead.
Common text file formats include .txt, .html, and .xml. For binary files, a huge number of formats exist, including .gif and .jpg for images, .wav for sound files, and .mid and .mpg for media files. In addition, program instructions are stored in a wide variety of formats, like .exe, .dll and .bin. Historically, such program instructions were called binaries.
To view and modify the contents of text files, simple text editors can be used that just convert the binary information to viewable characters and vice versa. If someone opens a binary file in a text editor, he or she will see lots of strange characters. Special viewers, such as hex viewers, are needed to read the contents. To modify one of these files properly, a person needs the appropriate application, such as a graphics editor to modify images.
Getting the content of a file is called reading, and putting in or modifying the contents is called writing. Applications for text files often read and write a whole line at a time, but for binary files, there is no universal equivalent to a line. As a result, they are read one byte at a time, and each byte must be interpreted. They must also be written one byte at a time.
Anyone can create their own file format for storing information and can interpret the ones and zeros in the binary file using their own application. For multiple people to use and share these files, however, standardization of formats is crucial. A number of experts come together and agree on standards. Some formats indicate how to interpret the information at the start of the file; this information is called a header or metadata. For example, a .gif file header indicates information about the several images that it contains.