Skip to main content
All posts

What Is a TXT File? Plain Text Files Explained

A TXT file stores plain text without formatting. See how it compares with Word and Markdown, why encoding matters, and how to open one on your device.

Basics

What is a TXT file?

A TXT file is a plain text document with a filename that usually ends in .txt. It stores characters such as letters, numbers, punctuation, spaces, and line breaks without the formatting and layout information used by word processors.

Open notes.txt in two different editors and you can see the same words in two different fonts. Each editor decides how to display those characters. If one editor uses a dark background and a larger font, those choices belong to the editor. A person receiving the file can read the same text with their own settings.

The name .txt describes the file's intended use. There is no single TXT specification that fixes an encoding, mandates a header, or defines a page size. Two valid TXT files can store the same words in different encodings, and one can use a different byte sequence for line breaks. For most everyday work, selecting UTF-8 and opening the result in a current text editor is enough.

What's inside a text file?

The file holds bytes. An encoding tells software how to interpret those bytes as characters. For example, Hi! followed by a line break can look like this in a hex viewer when saved as UTF-8 with LF:

48 69 21 0A

The first three bytes represent H, i, and !. The last byte is LF, a line-feed character. If you omit the line break, the file is three bytes long. If you use CRLF, the line ends with 0D 0A and the file is five bytes long. In a text editor both versions can appear identical.

Characters and bytes measure different things. The word café contains four letters. In UTF-8 it takes five bytes because é is encoded with two bytes. A typical Chinese character takes three bytes in UTF-8. Spaces and tabs can also take up space even though they are usually shown as blank. When an upload form sets a file-size limit, the number to check is the byte count after saving.

A TXT can still have structure that you can see. You can put a heading on a line by itself, separate paragraphs with blank lines, or make a list with literal dashes. A reader sees those same characters in another editor. To keep an image, a specific font, or a table with adjustable column widths, use a document format designed to store those things.

TXT vs DOCX vs RTF vs Markdown

FormatWhat the file containsTypical use
TXT (.txt)Plain characters, spacing, and line breaksNotes, logs, or simple handoffs
DOCX (.docx)A packaged document with styles, layout, and optional mediaAn editable Word document
RTF (.rtf)Text with instructions for fonts, styles, and other formattingSharing formatted text with a compatible editor
Markdown (.md)Plain text with conventions for headings, links, and other structureDocumentation or writing that can be rendered

Markdown is written as plain text. If you type # Meeting notes into a TXT file, an ordinary editor shows the hash and the words. A Markdown renderer can interpret the same line as a heading. You can write and review Markdown in a plain-text editor even when its final presentation will look different.

RTF is also easy to recognize if you open its raw contents in a text editor. You may see control words and braces that an RTF-aware application interprets as formatting instructions. In a Word document, the text is part of a package that also carries information such as layout and styles. Exporting a document as plain text extracts a text representation from that structure. Changing the filename alone leaves the original file structure intact.

Text encodings and garbled characters

UTF-8

Use UTF-8 for new text files in most situations. It represents English, accented letters, Chinese, emoji, and characters from many other scripts. Basic ASCII text has the same bytes in UTF-8. As a result, a small English-only test file may open correctly even when the sending and receiving programs disagree about the encoding. Test with the kinds of characters your real file contains.

ANSI and Windows-1252

Older Windows programs may label a save option ANSI. This refers to a Windows code page that depends on the system or application. Western European Windows setups often used Windows-1252. On another system, a different code page might be used, such as code page 936 for simplified Chinese. If a colleague sends a file described as ANSI, ask which program or machine produced it. Microsoft's guide to Windows code pages

UTF-16 and the byte order mark

UTF-16 stores text in 16-bit code units. A file can serialize those units in little-endian or big-endian order. A byte order mark, or BOM, can tell a reader which order to use. UTF-8 can also begin with a BOM, EF BB BF, as an encoding signature. Use a UTF-8 BOM if the recipient asks for it or a test shows it is needed. Some tools expect to see actual content at the first byte. Unicode's UTF and BOM FAQ

What to do when text looks wrong

If café opens as café, the reader may have interpreted the UTF-8 bytes as Windows-1252. Close the file without saving and reopen the original with the correct encoding. Once it displays correctly, save a UTF-8 copy if you need to move it between systems. If a previous export already replaced letters with question marks, you will need a copy that still contains the original characters. A different decoding setting cannot recover bytes that were lost when the file was written.

Line endings

Pressing Enter adds a line break. Common plain text conventions are LF, widely used in macOS and Linux workflows, and CRLF, traditional in Windows workflows. Many modern editors recognize either. If an older program shows every paragraph on one line or adds an unexpected character at each line end, check the difference between CRLF and LF.

A line ending is separate from wrapping. A long sentence can occupy three screen rows on a phone and one row on a monitor while remaining a single line in the file. To test whether the line actually ends, resize the window. A soft wrap moves when the available width changes.

How to open a TXT file on Windows, Mac, iPhone, and Android

  • Windows — Double-click the file or open it in Notepad. Windows TXT guide
  • Mac — Open the file in TextEdit or select it in Finder and press Space to preview. Mac TXT guide
  • iPhone — Locate the file in Files and tap it. iPhone TXT guide
  • Android — Open it from the file manager in a compatible viewer or editor. Android TXT guide

If the default viewer is read-only, open the same file from a text editor. Save a separate copy when you are unsure whether the editor will preserve the original encoding or line endings. This is especially helpful when the file will be fed into a program after you edit it.

How to create a TXT file

To create a text file online, type or paste your content, enter a filename, and download the file. UTF-8 works well for general sharing. If you are sending the result to software that requests a particular encoding or line ending, choose those settings before you download.

You can also use the text editor already on your computer. Save the document as plain text and check its full filename. If you started with an existing Word document, export a copy and compare it with the original. Confirm that the headings are understandable and that any data formerly in tables still makes sense when read line by line.

Common uses

  • Lists and notes. A shopping list, meeting agenda, or transcript can be easy to share in an attachment that does not depend on a particular word processor.
  • Logs. A developer or support team can search, copy, or compare messages across plain-text logs. Some use a .log extension to make their purpose clear.
  • Text exchanged between programs. A tool might expect an input file with one item per line. Follow that tool's rules for columns, encoding, and line breaks.
  • Documentation. A README.txt can explain the contents of an archive or give basic instructions before the reader installs any software.

Is a TXT file safe to open?

A genuine plain text document viewed in a text editor is passive data. Treat commands and links inside it the same way you would treat commands and links in an email. Before running a command from someone else, check what it does and whether the source is trustworthy.

On Windows, show file extensions if you are checking a suspicious attachment. A file named notes.txt.exe ends in .exe. An icon or the visible .txt portion of the name is insufficient to identify the file type when extensions are hidden. Microsoft Support on file name extensions

FAQ

Is every text file a TXT file?

TXT is the usual extension for unformatted general-purpose text. A text-based file can also have an extension such as .csv, .md, or .py that tells software how to interpret its contents. A text editor can display the characters in all of them.

Can a TXT file contain images or emoji?

Emoji can be saved as Unicode text in UTF-8. The device supplies the emoji glyphs. A photo requires its own file or a format that supports embedded images.

Can an empty file be a valid TXT?

Yes. A plain text file can contain zero bytes, in which case there is nothing to display. A file containing only a newline is different because it has at least one character.

Does TXT support passwords or encryption?

Plain text files have no built-in password protection. If you need to store sensitive text, the protection comes from the storage system or from a separate encrypted container.