What is a text file?
A text file is a file that only contains characters.
Specifically, the characters are represented by an agreed code (for example
65
for A
, 66
for B
…).
Importantly this means there is no formatting information encoded in the file itself: only characters.
Click or hover on the characters to see their underlying codes.
If you open a text file, and see text in different formats, you’re not just seeing the text file’s contents. Instead, you are seeing how a program is choosing to display it. So if some words are red, and others are in big font — those formatting features are not encoded directly in the file but are being added by the program you are using to look at it.
This is a subtle distinction. For example, a Word document does contain extra information that isn’t represented in this way. So a Word document is not a text file, even if it only contains the word “hello”.
It’s also a very important distinction if you are going to be doing any programming or using any command-line tools.