What is a correct MIME type for .docx, .pptx, etc.?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The correct MIME type for .docx is application/vnd.openxmlformats-officedocument.wordprocessingml.document. For .pptx it is application/vnd.openxmlformats-officedocument.presentationml.presentation. For .xlsx it is application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.
These are the IANA-registered types for Office Open XML formats introduced in Microsoft Office 2007. They are distinct from the older binary formats (.doc, .xls, .ppt) and must be set correctly for downloads, uploads, and content negotiation to work in web applications.
Complete MIME Type Reference
The table below covers all commonly encountered Microsoft Office formats, both legacy binary and modern Open XML:
| Extension | Format | MIME Type |
.doc | Word 97-2003 | application/msword |
.docx | Word 2007+ | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
.docm | Word macro-enabled | application/vnd.ms-word.document.macroEnabled.12 |
.dot | Word template (legacy) | application/msword |
.dotx | Word template | application/vnd.openxmlformats-officedocument.wordprocessingml.template |
.xls | Excel 97-2003 | application/vnd.ms-excel |
.xlsx | Excel 2007+ | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
.xlsm | Excel macro-enabled | application/vnd.ms-excel.sheet.macroEnabled.12 |
.xltx | Excel template | application/vnd.openxmlformats-officedocument.spreadsheetml.template |
.ppt | PowerPoint 97-2003 | application/vnd.ms-powerpoint |
.pptx | PowerPoint 2007+ | application/vnd.openxmlformats-officedocument.presentationml.presentation |
.pptm | PowerPoint macro-enabled | application/vnd.ms-powerpoint.presentation.macroEnabled.12 |
.potx | PowerPoint template | application/vnd.openxmlformats-officedocument.presentationml.template |
Why the MIME Types Are So Long
Office Open XML MIME types follow the IANA vnd. (vendor) naming convention. The structure breaks down as:
applicationis the top-level type for binary/structured data.vnd.openxmlformats-officedocumentidentifies the vendor and format family.wordprocessingml/spreadsheetml/presentationmlidentifies the Office application.document/sheet/presentation/templateidentifies the specific document type.
This verbose naming is intentional. It prevents ambiguity between document types that might otherwise share a generic type like application/xml.
Setting MIME Types in Web Servers
Nginx
Most Nginx installations include these mappings via /etc/nginx/mime.types. Check that file before adding custom types to avoid duplicates.
Apache
Apache's mod_mime uses AddType directives. These are typically already present in the default mime.types file, but you can add them explicitly:
Express.js (Node.js)
Express uses the mime package internally. Modern versions handle Office formats correctly by default. To override or verify:
Setting MIME Types for File Uploads
When accepting file uploads, validate the MIME type on the server side. Do not rely solely on the Content-Type header sent by the browser, because clients can set it to anything.
Python (Flask)
Java (Spring Boot)
Content-Disposition for Downloads
When serving Office files for download, set both Content-Type and Content-Disposition headers to ensure the browser downloads the file rather than trying to display it:
Without Content-Disposition: attachment, some browsers may attempt to open the file in a browser-based viewer or plugin, which may not be the intended behavior.
OOXML Files Are ZIP Archives
A useful fact for debugging: .docx, .xlsx, and .pptx files are ZIP archives containing XML files, media, and metadata. You can verify this:
This means that if a server sends application/zip for a .docx file, the file will download correctly but the operating system may not associate it with Word. The correct MIME type ensures the OS opens the right application.
Legacy vs Modern Format Comparison
| Feature | Legacy (.doc/.xls/.ppt) | Open XML (.docx/.xlsx/.pptx) |
| Internal format | Proprietary binary | ZIP of XML files |
| File size | Generally larger | Smaller (compressed) |
| Programmatic access | Requires specialized parsers | Standard XML/ZIP tools work |
| Macro support | Built-in | Separate extension (.docm, .xlsm) |
| Recovery | Difficult if corrupted | Individual XML parts may be recoverable |
| MIME prefix | application/msword, application/vnd.ms-* | application/vnd.openxmlformats-* |
Related Non-Microsoft Formats
Other office suites have their own MIME types that you may need to handle alongside Microsoft formats:
| Extension | Application | MIME Type |
.odt | OpenDocument Text | application/vnd.oasis.opendocument.text |
.ods | OpenDocument Spreadsheet | application/vnd.oasis.opendocument.spreadsheet |
.odp | OpenDocument Presentation | application/vnd.oasis.opendocument.presentation |
.pdf | application/pdf |
Common Pitfalls
Using application/octet-stream as a catch-all. This tells the browser "unknown binary data," which forces a download but prevents the OS from opening the file with the correct application. Always use the specific MIME type.
Serving .docx with application/msword. That is the MIME type for the legacy .doc format. While some applications handle the mismatch gracefully, others will reject the file or display an error.
Not validating MIME types on upload. The Content-Type header from the browser is user-controlled and can be spoofed. For security-sensitive applications, validate the file contents (check for the ZIP magic bytes PK and the [Content_Types].xml entry) rather than trusting the header alone.
Forgetting macro-enabled variants. Files with macros (.docm, .xlsm, .pptm) have different MIME types than their non-macro counterparts. If your application blocks macro-enabled uploads for security reasons, these must be checked separately.
Missing MIME types in cloud storage configuration. When serving files from S3, GCS, or Azure Blob Storage, the MIME type is stored as object metadata. If it was not set correctly during upload, downloads will use application/octet-stream by default. Set the Content-Type metadata explicitly during upload.
Summary
.docxusesapplication/vnd.openxmlformats-officedocument.wordprocessingml.document..xlsxusesapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet..pptxusesapplication/vnd.openxmlformats-officedocument.presentationml.presentation.- Legacy formats (
.doc,.xls,.ppt) use shorter MIME types likeapplication/msword. - Always set both
Content-TypeandContent-Dispositionwhen serving files for download. - Validate MIME types on the server during uploads. Do not trust client-sent headers alone.
- OOXML files are ZIP archives internally, which is why
application/ziptechnically works but produces incorrect OS behavior.

