Ffile2fix
Sign in Get started

What is a .txt file?

A .txt file holds plain, unformatted text with no fonts, images or layout. It is used for notes, README files, logs, exported data, licence files and config snippets, and opens in every text editor.

Key facts

  • MIME type text/plain; there is no header, so the encoding (UTF-8, UTF-16, Windows-1252, ...) must be guessed or declared.
  • Line endings differ by platform: CRLF on Windows, LF on Linux and macOS, CR on classic Mac OS.
  • A UTF-8 file may start with an optional byte order mark (EF BB BF), which some tools display as stray characters.
  • Size is simply the number of bytes of text; there is no formatting overhead.

How to open a .txt file

Windows

Double-click to open in Notepad, which handles UTF-8 and LF line endings on Windows 10/11. Notepad++ and VS Code show and change the encoding in the status bar.

macOS

Opens in TextEdit; use Format > Make Plain Text to keep it unformatted. BBEdit and VS Code give more control over encoding and line endings.

Linux

Read it with less file.txt or cat file.txt, edit with nano or vim, and detect the encoding with file -i file.txt.

Common problems and fixes

Text shows garbled characters such as é or �
The file is being read with the wrong encoding, typically UTF-8 shown as Windows-1252 or vice versa. Reopen it with the correct encoding and re-save as UTF-8, e.g. iconv -f WINDOWS-1252 -t UTF-8 in.txt > out.txt.
Everything appears on one line or has ^M characters
The line endings do not match the tool reading them. Convert them with dos2unix/unix2dos or your editor's line-ending setting.
Strange characters () at the start of the file
A UTF-8 BOM is being shown as text. Save the file as 'UTF-8 without BOM', which matters for scripts, CSVs and config files.
Text has spaces between every letter or looks binary
The file is UTF-16 (common for Windows exports) and the viewer expects UTF-8. Open it as UTF-16 and convert it to UTF-8.

Often converted to or from: DOCX, PDF, Markdown, CSV, HTML

Frequently asked questions

What is the difference between .txt and .docx?

A .txt file is just characters, while .docx is a zipped package of XML with formatting, images and styles. Text files are smaller and universal but cannot store bold, fonts or layout.

Which encoding should I save text files in?

UTF-8 without BOM. It supports every language, is the default on the web, Linux and macOS, and is read correctly by modern Windows tools.

Can a .txt file contain a virus?

A genuine text file cannot execute. Be wary of names like invoice.txt.exe or .txt.js with hidden extensions, which are programs pretending to be text.

See all file types → · Browse error fixes →