← Blog

Document Types and Their MIME Types: A Developer's Reference

"Document type" is a slippery phrase. To a user it means "the kind of file this is" β€” Word document, Excel sheet, PDF. To a browser it means an Internet Media Type, a label from a public registry that identifies exactly which bytes the file contains. Most bugs in file-handling code come from mixing the two: trusting an extension when you should trust a MIME type, or checking one MIME string when five are valid.

This article is a reference for every document type you are likely to see on the web or on the clipboard, with the MIME strings each one reports, the legacy strings some older servers still emit, the magic bytes that identify the format in the absence of a reliable label, and the gotchas that break naive validators.

What a MIME type is (and isn't)

A MIME type β€” officially an Internet Media Type β€” is a two-part string of the form type/subtype. The type describes the broad category (application, image, text, audio, video, font); the subtype identifies the specific format. For documents you will mostly see application/* and a handful of text/* entries.

A MIME type is descriptive, not prescriptive. It is what the source says the bytes are. If the source is wrong, the MIME type is wrong. Treat it as a strong hint, verify with magic-byte sniffing when security matters, and never use the extension alone.

Microsoft Office documents

Office files come in two generations. The legacy binary formats (.doc, .xls, .ppt) date from the 90s; the modern Office Open XML formats (.docx, .xlsx, .pptx) replaced them with Office 2007. Both still appear in uploads, so any validator should accept both.

Microsoft Word (.doc, .docx)

  • Modern (.docx): application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • Legacy (.doc): application/msword
  • Template (.dotx): application/vnd.openxmlformats-officedocument.wordprocessingml.template
  • Macro-enabled (.docm): application/vnd.ms-word.document.macroEnabled.12
  • Magic bytes (.docx): 50 4B 03 04 β€” it is a ZIP archive with [Content_Types].xml inside

Microsoft Excel (.xls, .xlsx)

  • Modern (.xlsx): application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • Legacy (.xls): application/vnd.ms-excel
  • Binary workbook (.xlsb): application/vnd.ms-excel.sheet.binary.macroEnabled.12
  • Macro-enabled (.xlsm): application/vnd.ms-excel.sheet.macroEnabled.12
  • Gotcha: Excel CSV exports arrive as text/csv on modern systems but as application/vnd.ms-excel on older Windows installs. Accept both for CSV endpoints.

Microsoft PowerPoint (.ppt, .pptx)

  • Modern (.pptx): application/vnd.openxmlformats-officedocument.presentationml.presentation
  • Legacy (.ppt): application/vnd.ms-powerpoint

PDF and portable documents

  • PDF: application/pdf
  • Legacy alternate: application/x-pdf β€” rare but still seen from old servers
  • PDF/A (archival): same MIME type; the distinction is in the PDF internals
  • Magic bytes: 25 50 44 46 (%PDF) at offset 0

Never trust a PDF based on the MIME header alone for sensitive features. A renamed .html file served as application/pdf will still be rendered by some browsers and read by some parsers, with predictable results.

OpenDocument and other office formats

  • OpenDocument Text (.odt): application/vnd.oasis.opendocument.text
  • OpenDocument Spreadsheet (.ods): application/vnd.oasis.opendocument.spreadsheet
  • OpenDocument Presentation (.odp): application/vnd.oasis.opendocument.presentation
  • EPUB (.epub): application/epub+zip
  • RTF (.rtf): application/rtf (legacy text/rtf still occurs)
  • Apple Pages (.pages): application/vnd.apple.pages
  • Apple Numbers (.numbers): application/vnd.apple.numbers

Plain-text document formats

  • Plain text (.txt): text/plain
  • Markdown (.md): text/markdown (legacy: text/x-markdown)
  • CSV (.csv): text/csv
  • TSV (.tsv): text/tab-separated-values
  • JSON (.json): application/json
  • XML (.xml): application/xml (legacy: text/xml; both are valid)
  • YAML (.yml, .yaml): application/x-yaml or text/yaml β€” not registered, seen in both forms

How to accept a document type in an upload handler

Naive validators reject too many real files. The robust pattern:

const DOC_TYPES = new Set([
  // Word
  'application/msword',
  'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  // Excel
  'application/vnd.ms-excel',
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  // PowerPoint
  'application/vnd.ms-powerpoint',
  'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  // PDF
  'application/pdf',
  // Open formats
  'application/vnd.oasis.opendocument.text',
  'application/vnd.oasis.opendocument.spreadsheet',
  'application/vnd.oasis.opendocument.presentation',
  // Generic
  'application/octet-stream',  // browsers fall back to this when they can't identify
])

function isDocument(file) {
  if (DOC_TYPES.has(file.type)) return true
  // Fall back to extension only if MIME is missing / octet-stream
  const ext = file.name.toLowerCase().match(/\.[^.]+$/)?.[0]
  return ext && ['.doc','.docx','.xls','.xlsx','.ppt','.pptx','.pdf','.odt','.ods','.odp','.rtf','.txt','.csv'].includes(ext)
}

For security-sensitive uploads (anything server-rendered to another user), follow this validation with magic-byte sniffing on the server. Browsers are trusting; servers must not be.

Reading a document from the clipboard

When a user copies from a document and pastes into your web app, you rarely see the underlying document file β€” you see extracted content in multiple formats. Copying a paragraph from Word produces:

  • text/plain β€” the unformatted string
  • text/html β€” HTML wrapped in a StartFragment/EndFragment comment with heavy inline styles
  • application/x-officedraw β€” Word's round-trip format

Copying a range from Excel produces:

  • text/plain β€” tab-separated values with newlines between rows
  • text/html β€” a full HTML <table> with cell styles

To see the real payload for any document copy, paste it into Clipboard Inspector β€” every MIME type is listed with its decoded value. For a deep dive on spreadsheet pastes specifically, see Parsing Pasted Spreadsheet Data.

Legacy MIME gotchas worth knowing

  • application/x-download β€” IE-era alias for any "force-download" file. You still see it on old intranets. Treat as application/octet-stream.
  • application/force-download β€” another IE-era alias. Same treatment.
  • image/pjpeg β€” progressive JPEG on old IE. Treat as image/jpeg.
  • text/xml vs application/xml β€” both valid; pick application/xml for new code.
  • Empty or missing MIME on Safari uploads β€” iOS Safari sometimes reports '' for some file types. Fall back to the extension.

Quick reference: document extension to canonical MIME

ExtensionCanonical MIME type
.pdfapplication/pdf
.docapplication/msword
.docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
.xlsapplication/vnd.ms-excel
.xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.pptapplication/vnd.ms-powerpoint
.pptxapplication/vnd.openxmlformats-officedocument.presentationml.presentation
.odtapplication/vnd.oasis.opendocument.text
.odsapplication/vnd.oasis.opendocument.spreadsheet
.rtfapplication/rtf
.txttext/plain
.csvtext/csv
.jsonapplication/json
.xmlapplication/xml
.mdtext/markdown
.epubapplication/epub+zip

Need the full file-type reference, not just documents? See File Types & MIME Types: Complete Reference.