Text lives in many kinds of files. Some are plain text with conventions on top; others are structured packages or page descriptions. Knowing which is which explains why some files open anywhere and others need specific software.

Plain-text formats

These can be opened in any text editor.

ExtensionContainsTypical use
.txtUnstructured textNotes, logs, simple exports
.csv / .tsvRows of values separated by commas or tabsSpreadsheet and database exchange
.mdText with Markdown formatting marksDocumentation, README files, notes
.htmlText with HTML tagsWeb pages, email bodies
.jsonStructured data: objects, arrays, strings, numbersAPIs, configuration
.xmlStructured data in nested tagsFeeds, configuration, document standards
.srt / .vttNumbered, timed caption blocksSubtitles

Plain text is the most durable format: it has no required software, works with version control, and can be searched and processed by simple tools. Its main weaknesses are ambiguity about encoding and line endings, and the lack of built-in formatting.

CSV deserves a note: the common specification (RFC 4180) quotes fields that contain commas, quotes or line breaks, but many programs deviate from it. Delimiters, quoting and encoding vary, which is why CSV imports so often go wrong.

Rich-text and word-processor formats

ExtensionContains
.rtfPlain text with formatting control words ({\b bold}); readable but cluttered
.docxA ZIP archive of XML files (Office Open XML): text, styles, images, metadata
.odtA ZIP archive of XML files (OpenDocument), used by LibreOffice
.epubA ZIP archive of XHTML pages, CSS and images, for e-books

Rename a .docx to .zip and open it, and you will find word/document.xml holding the text. That structure preserves formatting, comments and tracked changes, but you need an application that understands it.

PDF

A PDF describes how pages look: it places glyphs at positions on fixed-size pages. It does not necessarily store text in reading order, or store paragraphs at all. That is why copying from a PDF produces broken lines, hyphenated fragments and occasionally scrambled order or missing spaces, and why scanned PDFs contain no text unless OCR has been applied. See how to clean pasted text.

Choosing a format

  • For text that must last and be processed by tools: .txt, .md or .csv in UTF-8.
  • For documents others will edit with formatting: .docx or .odt.
  • For fixed-layout distribution and printing: .pdf.
  • For the web: .html.