Plain Text and Binary Files
Level 1 · Files and formats
How a plain text file differs from a binary one. Why a ZIP file shrinks text but not photos, and why a PDF looks the same on every screen.
Course contentsLesson 2 of 11
Level 1 · Files and formats
Level 2 · Data formats
Level 3 · Config and docs files
Level 4 · Characters and escapes
Level 5 · IDs, dates and patterns
After this lesson you can
- Tell a text file from a binary file
- Say what a ZIP file does to text and to photos
- Explain what a PDF keeps fixed
11 mincovers 4 glossary entries
Worth reading first: File Formats and Extensions
What makes a file text, and what makes it binary
A plain text file holds only characters you can read: letters, digits and signs. Code, JSON, CSV and Markdown files are all plain text. A binary file holds raw bytes that are not meant as text, like a photo, a song or an app. A page of text is a few kilobytes, while one phone photo is a few megabytes.
Plain text has big upsides. Any text editor can open it, on any computer, years from now. Tools like Git can show which lines changed. You can read it and fix it by hand.
Binary files win on size and speed. Open one in a text editor and you see a mess of odd signs. A photo stored as text would be huge and slow to load. Only a program that knows the format can read one, so you open it with the right app, not a text editor.
A ZIP file packs many files and folders into one binary file. It usually squeezes them too, which is called compression. Nothing is lost: unzipping gives back the exact same bytes. Text often shrinks to a tenth of its size or less.
Photos, music and videos barely shrink in a ZIP. Formats like JPG are already squeezed, so there is little left to take out. Zip a folder of photos to send it as one file, not to save space.
A PDF is a binary format that keeps a page looking the same everywhere. It stores the exact place of every word and picture, and it carries its own fonts. Adobe made it in 1993, and it became an open ISO standard in 2008.
The price of a fixed page is that it does not flow. On a phone, a PDF page just shrinks, while a web page moves its parts to fit. Editing a PDF is hard for the same reason. Use it for things you print, sign or send to keep.
$ zip notes.zip notes.txt
adding: notes.txt (deflated 94%)Worked example
Jack sends a folder of photos
Jack zips 40 holiday photos, 120 megabytes in all, hoping to make them small. The ZIP file comes out at 118 megabytes.
The photos were already squeezed as JPG files. The ZIP still helps, because now he sends 1 file, not 40.
The words for this lesson4
Check yourself
Why does a ZIP of photos come out about the same size?
Finished this lesson?
Marking it complete also marks its 4 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.