Difference Between Text File & Binary File

Text file and binary files are extensively used in programming. In this article we are going to point out the major difference between text file and binary file.


In text file, text, character, numbers are stored one character per byte i.e. 32667 occupies 5 bytes even though it occupies 2 bytes in memory.
In binary file data is stored in binary format and each data would occupy the same number of bytes on disks as it occupies in memory.

In the text file, the newline character is converted to carriage-return/linefeed before being written to the disk.
In binary file, conversion of newline to carriage-return and linefeed does not take place.

Text files are used to store data more user friendly.
Binary files are used to store data more compactly.

In the text file, a special character whose ASCII value is 26 inserted after the last character to mark the end of file.
In the binary file no such character is present. Files keep track of the end of the file from the number of characters present.

Content written in text files is human readable.
Content written in binary files is not human readable and looks like encrypted content.