Plain Text MIME Type
text/plain means, how character encoding affects .txt files, and how Poly previews, searches, and reads plain text. MIME type details for text/plain
In active use| MIME type | text/plain |
|---|---|
| Extensions | .txt |
| First standardized | 1992 |
| Created by | Nathaniel Borenstein and Ned Freed |
| Browser support | Chrome, Edge, Firefox, Opera, Safari |
| Example applications | Apple TextEdit, Visual Studio Code |
| Poly support | Yes. Poly recognizes `.txt` files and readable UTF-8 content, preserving the text for useful file experiences. |
| Indexed by Poly | Yes. Poly indexes plain-text filenames and readable content for exact and meaning-based search. |
| Preview in Poly | Yes. Plain text opens in a code-friendly editor with wrapping and optional filename-based syntax highlighting. |
| Poly agent | Yes. The Poly agent can read and reason about the file's text, including requested line ranges. UTF-8 gives the most reliable results. |
What does text/plain mean?
The text/plain media type identifies a linear sequence of characters with no required formatting commands, font attributes, processing instructions, or markup. Line breaks and page breaks may divide the text, but the type does not assign document structure to headings, lists, links, or tables.1
That makes text/plain deliberately broad. A grocery list, source-code sample, log, README, or configuration file can all be plain text at the byte level. More specific media types such as text/csv, text/html, or text/javascript should be used when the receiver needs the content's particular syntax and semantics.
The conventional filename extension is .txt. Plain text has no magic number. The opening bytes depend on what the text says and how its characters are encoded, so a signature cannot reliably distinguish it from source code or another textual format. RFC 5147 describes .txt as the commonly used suffix, rather than part of the media type itself.2
.txt does not remove its formatting or convert its bytes. Export it as plain text from the original application, then open the result and check the characters.A short history of text/plain
People stored character data long before MIME existed. The media type itself appeared in June 1992 in RFC 1341, the original MIME specification by Nathaniel Borenstein and Ned Freed.3 RFC 2046 replaced that document in 1996 and remains the core definition referenced by IANA.14
Later standards added narrowly scoped behavior without turning plain text into a rich document format. RFC 3676 defines optional format=flowed and delsp parameters for mail messages whose paragraphs may be rewrapped. If format is absent, fixed lines are assumed.5 RFC 5147 defines URI fragments that can identify character or line ranges in a text/plain resource.2
Which character encoding should a plain-text file use?
text/plain describes characters, but bytes still need a character encoding. In MIME, the optional charset parameter declares it:
Content-Type: text/plain; charset=utf-8
The formal default for text/plain remains US-ASCII when no charset is supplied.6 In modern files and HTTP responses, UTF-8 is usually the most interoperable choice because it represents ASCII and the full Unicode repertoire. Declaring charset=utf-8 also avoids relying on software to guess.
MIME's canonical representation uses CRLF for line breaks.1 Files stored locally commonly use LF on Unix-like systems and CRLF on Windows. Most current editors accept either, but command-line scripts, checksums, and version-control diffs can expose the difference.
How to open a TXT file
Current browsers display a response sent as text/plain, and .txt files open in ordinary text and code editors.7 Useful choices include:
- Apple TextEdit, which can create, open, save, and convert plain-text documents.8
- Visual Studio Code, which lets you choose an encoding and a language mode for editing.9
- A browser when the file is available over HTTP with the correct
Content-Typeandcharset.
A filename does not control an HTTP response. Serve raw text as text/plain, include the correct charset, and use X-Content-Type-Options: nosniff when you need browsers to honor the declared type rather than infer another one.7
Support in Poly
Poly gives plain-text files content-aware support. According to Supported File Types, Poly:
- Opens
.txtfiles in a code-friendly editor with line wrapping and optional filename-based syntax highlighting. - Indexes readable text for exact and meaning-based search.
- Lets search results focus the relevant text range.
- Makes the file's readable content available to the Poly agent.
Poly also recognizes readable UTF-8 content when a filename does not identify a known format. Files in an unusual legacy encoding, or binary files mislabeled as text/plain, may not preview or search as intended. Convert genuine text to UTF-8 and keep a meaningful extension when possible.
Plain text compared with nearby formats
| Format | What it preserves | Best use |
|---|---|---|
Plain text (.txt) | Characters and line breaks | Notes, logs, portable text, simple interchange |
Markdown (.md) | Text plus lightweight markup conventions | Readable source that can also render as a structured document |
CSV (.csv) | Delimited records and fields | Tabular data exchange |
HTML (.html) | Structured markup interpreted by a browser | Web documents and interfaces |
RTF (.rtf) | Fonts, styles, and other document formatting | Editable formatted documents |
Plain text is often the safest export when preserving readable words matters more than layout. It cannot retain images, fonts, hyperlinks as active objects, comments, tracked changes, spreadsheet formulas, or page design.
Is text/plain safe?
Serving untrusted words as text/plain is safer than labeling them as executable script or active HTML, but plain text is not automatically harmless. RFC 5147 warns that control characters can affect terminals, bidirectional text can mislead readers, and very large lines or files can stress software.2
The media type also does not validate the content. A file containing HTML tags remains plain text when served as text/plain; changing its header to text/html changes how a browser interprets those same bytes.
Converting to and from plain text
Choose the conversion based on what must survive:
- From a word processor, export as
.txtwhen only the words and line breaks matter. Formatting, images, and page layout are discarded. - From a spreadsheet, use CSV or tab-separated text when rows and columns matter.
- From HTML or Markdown, use a parser or the application's export command if you want visible text without markup.
- To create a formatted document from plain text, import it into a word processor and add structure manually. The original file contains no reliable styling instructions to restore.
Apple notes that converting a rich-text document to plain text removes its styles and saves it as .txt.8 Keep the original whenever you may need its formatting later.
Footnotes
- Internet Engineering Task Force. RFC 2046: Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types. Defines
text/plain, thecharsetparameter, and canonical MIME line breaks. ↩ ↩2 ↩3 - Internet Engineering Task Force. RFC 5147: URI Fragment Identifiers for the
text/plainMedia Type. Describes plain text, the conventional.txtsuffix, line and character fragments, interoperability, and security considerations. ↩ ↩2 ↩3 - Internet Engineering Task Force. RFC 1341: MIME (Multipurpose Internet Mail Extensions). The June 1992 specification introduced the
text/plainsubtype and names Nathaniel Borenstein and Ned Freed as authors. ↩ - Internet Assigned Numbers Authority. Media Types Registry:
text/plain. Liststext/plainwith RFC 2046, RFC 3676, and RFC 5147 as references. ↩ - Internet Engineering Task Force. RFC 3676: The Text/Plain Format and DelSp Parameters. Defines fixed and flowed text for Internet mail. ↩
- Internet Engineering Task Force. RFC 6657: Update to MIME Regarding Charset Parameter Handling in Textual Media Types. Confirms that the default charset for
text/plainremains US-ASCII and recommends explicit charset information. ↩ - MDN Web Docs. Content-Type Header. Explains declaring media types and using
X-Content-Type-Options: nosniffto prevent MIME sniffing. ↩ ↩2 - Apple Support. Create, Open, and Convert Documents in TextEdit on Mac. Documents plain-text creation, opening, conversion, and the loss of formatting when converting to
.txt. ↩ ↩2 - Microsoft. Basic Editing in Visual Studio Code. Documents file editing, language modes, and file-encoding controls. ↩