Text file

.txt · Documents

A .txt file contains nothing but characters: no fonts, no bold, no images, no page layout. That is its strength. A text file written in 1985 can still be read today with any editor on any device, and it will be readable in fifty years. You meet TXT files as README files, logs, exported notes, subtitles in disguise, lists from phones and data dumps from older systems.

A file without a format

Strictly speaking, TXT is not a file format but a convention. The extension says “this is text” and nothing else; there is no header, no version and no standard of its own. On the internet such content is labelled with the media type text/plain, defined in RFC 2046. Two hidden properties decide whether a text file displays correctly: the character encoding and the line endings.

Character encoding

Computers store numbers, and the encoding says which number means which letter. The first 128 characters (ASCII, 1963) are the same everywhere. Beyond that, there were dozens of incompatible tables for decades: Windows-1252 for Western Europe, Windows-1250 and ISO 8859-2 for Central Europe, and others. A file says nothing about which table it uses.

Today the standard is UTF-8 (RFC 3629). It covers every script, and plain ASCII text is valid UTF-8 unchanged. Some programs put three invisible bytes, EF BB BF, at the start of a UTF-8 file. This byte order mark (BOM) helps editors recognise the encoding but can confuse scripts and some import tools. Windows Notepad has saved new files as UTF-8 without BOM since Windows 10 version 1903 (2019); before that the default was the legacy Windows code page.

Line endings

Windows ends each line with two control characters (CR LF), Linux and macOS with one (LF), and classic Mac OS before 2001 used CR alone. Files moved between systems may appear as one long line or with blank lines in between. Notepad has understood Unix line endings since Windows 10 version 1809; older tools have not.

How to open and edit TXT

  • Windows: Notepad; for large files or encoding work, free editors such as Notepad++ or Visual Studio Code.
  • macOS: TextEdit (switch to Format > Make Plain Text when creating a new file), BBEdit, VS Code.
  • Linux: any editor: gedit, Kate, nano, vim.
  • Phone: the built-in file viewers on Android and iOS show TXT; for editing, any note or text editor app.

Common problems

TXT shows strange characters instead of accented letters

Typical mojibake: “é” instead of “é”, or “ü” instead of “ü”. The file is UTF-8 but the program read it as Windows-1252. The opposite case, a legacy file opened as UTF-8, shows replacement symbols such as “�”. The text is not damaged. Open the file in an editor that lets you choose the encoding (in Notepad++ the Encoding menu, in LibreOffice File > Open with the file type “Text – Choose Encoding”), pick the right one and save it as UTF-8.

Everything is on one line

Unix line endings opened in an old Windows program. Open the file in a current editor and save it again, or convert line endings in Notepad++ (Edit > EOL Conversion).

The TXT file is too large to open

Logs of several hundred megabytes overwhelm Notepad and word processors. Use an editor built for large files, or on Linux and macOS view it with less.

Converting TXT

TXT is often converted to PDF to print or submit a fixed copy, to DOCX or ODT to continue with formatting, or to EPUB to read longer texts on an e-reader. Our converter sets the text in a default font and page size, and you can format the result further. UTF-8 input gives the most reliable results with accented characters. In the other direction, any DOCX, ODT, RTF, HTML or e-book can be reduced to plain text; our TXT output is always UTF-8. A text-based PDF can be converted to TXT as well, while a scan or photo of a page goes through OCR: we recognise the text of the first page or image, including Czech and German diacritics.

TXT in brief

Developernone; convention as old as computing
Media typetext/plain (RFC 2046)
Recommended encodingUTF-8 (RFC 3629), with or without BOM
Line endingsCR LF (Windows), LF (Linux, macOS)
Formatting, imagesnone
Compressionnone
Typical usenotes, README files, logs, configuration, data exports

We can convert TXT into

Documents

PDF DOCX DOC ODT HTMLDOCMDOTDOTXFODTOTT RTFUOTPDF/AABWAWTFOZABW

Images

JPG PNGWEBP GIF TIFFHEICAVIFJXLPSDICOAAIAPNGARTAVS BMP CINCURDCXDDSDPXFF FITSFL32 HDRHRZJP2JBIGJNGJPCMNGMTVOTBPALMPAM PBMPCD PCXPFMPGMPGXPHMPICTPPMPSBPTIFQOIRASRGFSGISIXELSUN TGAVICARVIFFVIPS WBMPXBMXPMXWDDCM

Vector images

SVG EPSEMFFXGHPGLPOV PSSIFSVGZWMFXAML

eBooks

EPUB MOBI AZW3 FB2CBZHTMLZ LIT LRF OEB PDB TCRTXTZCB7CBTDJVU

Markup languages

MDTEXRSTADOCWIKIORGDOCBOOKCONTEXTDOKUWIKIHADDOCKICMLIPYNBJATSJIRAMANMSMUSEOPMLTEITEXITEXTILETYPXWIKIZIM