Everything you need to know about TXT
TXT (.txt) is plain text - the most universal, most boring, most enduring file format on Earth. A TXT file is a sequence of characters with newlines. No formatting, no fonts, no metadata. It's the lowest common denominator and the highest reliability format we have.
How it works under the hood
- Character encoding. UTF-8 is the modern standard - any Unicode character. ASCII is the historical baseline (7-bit, 128 characters). Windows-1252, Mac OS Roman, UTF-16 still appear in legacy files.
- Line endings vary. LF (`\n`) on Unix/macOS, CRLF (`\r\n`) on Windows, CR (`\r`) on classic Mac. Mixing them can break tools that expect a specific format.
- BOM (Byte Order Mark). UTF-8 BOM is `0xEF 0xBB 0xBF` at file start. Notepad adds it; most Unix tools hate it. Optional and often unwanted.
- No structure. TXT has no concept of sections, lists, or formatting. That's its strength - any program that handles strings handles TXT.
Where you'll actually use it
- README files and changelogs
- Log files (server logs, debug output)
- Configuration files (when JSON/YAML is overkill)
- Any cross-platform data exchange where structure isn't needed
How it compares to alternatives
TXT vs MD: Markdown is TXT with conventions for headers, lists, links. TXT vs RTF: RTF has formatting; TXT doesn't. TXT vs JSON: JSON is structured; TXT is freeform.
Things that will trip you up
- UTF-8 vs Latin-1 mismatches mangle international characters - always specify encoding
- Editors that 'fix' line endings can break shell scripts running on different OSes
- Excel imports TXT poorly - dates and numbers get auto-converted in surprising ways
Test it yourself: Any text editor (VS Code, Notepad, vim, nano). `file --mime-encoding sample.txt` reveals the encoding. `iconv` converts between encodings.