Text vs. Binary Files

Robert Mundinger
CodeParticles
Published in
3 min readDec 11, 2017

In Computer Science, every file is just a pile of 1s and 0s, but (I want to distinguish between) there are really 2 types of files. Human readable vs. non-human readable. Text vs. binary.

You can open any file on your computer here and see that each is just a bucket of 1s and 0s (although they will show here as hexidecimal — just another number system. See the ASCII chart below).

(youtube — opening any file)

The file extension on files are only there to let the operating system what ‘default program’ to use when running the file.

But to explain the difference between text and binary, let’s look at what a .txt file looks like vs. a Microsoft Word file (.docx).

YouTube- writing “hello, my name is Robert” in both text and binary.

https://mapfiles.blob.core.windows.net/tutorials/Robert.txt

https://mapfiles.blob.core.windows.net/tutorials/Robert.docx

hex-works.com

A .txt file

The first can be controlled with code and the second typically needs an SDK to interact with it. For instance, if I want to write an Excel file I have to use a library to

(open source vs. proprietary)

Or .csv file (comma separated values) and a .xlsx file (Excel file).

It’s the reason an .xlsx file can have formatting like cell colors, tables, formulas, etc. while a .csv file can’t have any of that. Same with a word file…you can have underlining, bold, italics, fonts, etc. whereas in a .txt file you can’t have any of that. All that extra formatting has to be encoded into the file itself, which makes it far more complex.

CSV opens in Excel:

CSV:

--

--