Binary file

from Wikipedia, the free encyclopedia

A binary file ( English binary file ) is a computer file that no text file is that not only representations , printable 'character includes, but any bit pattern may contain. Depending on the format, binary files can also contain data parts that can be interpreted as texts / characters.

Most computer programs use files in binary format to structurally align the data with the processing requirements or to save certain data fields in an optimized manner. In particular, directly executable programs are also saved as binary files and are often called " binary code ".


In principle, binary files can be recognized as such by the fact that the file content, displayed with a standard text editor , contains no or mostly no readable characters. Attempting to interpret a binary file as a text file (for example by opening it with a text editor) then results in illegible or nonsensical text. The following applies to most of the 8-bit character sets used today: unreadable control characters include characters with ASCII values ​​from 0 to 31, readable characters those with values ​​from 32 to 126. The legibility of characters with values ​​from 127 depends on the character set used . Text files can also contain certain control characters without being considered binary files; this includes control characters for line feed , carriage return , page break (page feed) and tab characters .

Because binary files use all possible bit combinations, they offer a higher information density than text files. Therefore they usually require less storage space on mass storage devices and can be loaded and saved more quickly. Furthermore, different object types (for example text with images) can be stored in it relatively easily.

Binary formats are not damaged when exchanged across different platforms (e.g. Windows, Macintosh, Linux) because the respective software components do not attempt to convert the files for the target platform. On the other hand, cross-system data exchange is made more difficult because binary files often contain data in a system-dependent format. (For example, numbers in big or little-endian format.) The specification of the file format of a binary file determines what to do with the file. To read, edit and save binary data formats you generally need special editors that are matched to the file format ( e.g. word processing for office texts, an image processing program for photos, regedit for the Windows registry database ).

It should be noted that a binary file or binary format does not mean data that is only made up of the (visible) characters “0” and “1” - as the name analogy to hex (adecimal) file might suggest. Binary file does not mean that the data only consists of binary "0" and "1" - because this is also the case with text character sets. A file that has been created by a word processing program is usually (depending on the file format) not a pure text file in the narrower sense, but a binary file in which, for example, format information and other control characters are not encoded with a readable character set . Such files, for example in rich text format , are in this respect a mixture of text and binary files.


Computer programs are a typical example of binary files because they contain processor instructions and data that can take any byte value. For this reason, the executable files of compiled programs are often simply called 'binaries'. In contrast, the source text is often saved as a text file.

Further examples of binary files are image files , audio files , compressed files (archive files), data for spreadsheet programs , data from extensive office packages , data managed with database systems and the like. v. a.

Convert binary file to text

Binary files are also occasionally encoded in a plain text representation in order to avoid interference during transmission between different computer systems. Coding schemes such as Base64 (or similar ones , such as the rarely used Base85 or basE91) as well as UUE and MIME formats are used for this.

View binary files

Display a binary file with two different commands: more (for text files) and od (for binary files).

Additional software is required to view the unadulterated content of a binary file. Hex editors are used for this task . If, on the other hand, an attempt is made to view a binary file with a text editor or on the command line level, the content is displayed incorrectly (see picture). This is due to the fact that certain bytes or whole byte sequences are interpreted as control characters or control sequences. In most cases, this manifests itself in a concert of frequent beeps (e.g. with Bell control characters ), a mess of characters or even no output at all. The reason for this is that all possible 256 states of an octet can often be found in binary files .

Useful tools for viewing the content of binary files under Unix and Linux are od (abbreviation for octal dump - octal memory dump ), hexdump (for hexadecimal dump ) or strings .

How the eight bits of an octet are used to represent decimal or hexadecimal numbers is described under dual system .

See also