Utilo

DOCX MIME Type – Free, Online, Private

A .docx file is a ZIP package of XML parts. Its type is the long Open XML wordprocessingml type, not application/zip.

What .docx is

DOCX is the Office Open XML word-processing package. The file is a ZIP archive, magic PK, whose parts include [Content_Types].xml and word/document.xml. IANA registers application/vnd.openxmlformats-officedocument.wordprocessingml.document for that package. application/zip would be technically true of the container and wrong for every client that has to decide whether to unzip or to open a word processor. The older binary .doc format is application/msword and is not this file. A template .dotx has its own registered type. Do not reuse the document type for a template if you can avoid it.

IANA registers application/vnd.openxmlformats-officedocument.wordprocessingml.document. The media type is application/vnd.openxmlformats-officedocument.wordprocessingml.document. Extensions that use it on this page: .docx. A client compares the type, not the filename, once the response has arrived. The filename still matters on disk and in Content-Disposition, which is why a wrong extension and a wrong header are two different bugs.

What sends application/vnd.openxmlformats-officedocument.wordprocessingml.document

What sends application/vnd.openxmlformats-officedocument.wordprocessingml.document: Send the full wordprocessingml type for a .docx download. The string is long. Copy it from this page rather than shortening it. Set a filename ending in .docx so the operating system can associate the file even if a client ignores the header. Do not add a charset. The ZIP is binary and the XML inside is UTF-8 by the Open XML rules, not by an HTTP parameter. If you generate the package, finish the central directory before you end the response. A truncated ZIP is a document nobody can open, with a correct type. The file on disk is still .docx. Once the response exists, a client trusts application/vnd.openxmlformats-officedocument.wordprocessingml.document, not the filename. If you convert the document to PDF for preview, the preview URL is application/pdf and the original URL stays the wordprocessingml type. Do not replace the original bytes with a PDF under the same path. Clients that already saved the URL will store a PDF under a .docx name.

Content-Type for .docx

Send application/vnd.openxmlformats-officedocument.wordprocessingml.document and do not add a charset parameter. The body is binary. A charset tells a text decoder to reinterpret bytes that are not text, which corrupts a download and does not help a browser sniff the format.

Content-TypeContent-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

nginx, Apache, and Express

These snippets map .docx to application/vnd.openxmlformats-officedocument.wordprocessingml.document. nginx reads the types block when it picks a type from the URL's extension. A location that sets default_type, or an application that sets the header itself, overrides that map. Apache AddType applies in the directory context where you put it. The Express static example writes the header for files ending in .docx so a stale mime database in the framework cannot disagree with the type on this page.

nginx# /etc/nginx/mime.types, inside the types { } block
application/vnd.openxmlformats-officedocument.wordprocessingml.document  docx;
ApacheAddType application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx
Expressimport express from "express";

const app = express();
app.use(express.static("public", {
  setHeaders(res, filePath) {
    if (filePath.endsWith(".docx")) {
      res.setHeader("Content-Type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
    }
  },
}));

Pitfalls for application/vnd.openxmlformats-officedocument.wordprocessingml.document

Pitfalls that show up for application/vnd.openxmlformats-officedocument.wordprocessingml.document, and not for a neighboring type with a similar extension: A route that hard-codes application/zip will make browsers download a zip and make Word refuse to open it from the zip UI. Send the specific type. A second bug is a .docx that is really a .doc renamed, or an HTML file some exporters used to wrap as Word. Check for PK and for [Content_Types].xml. A third is an error page of text/html saved by a client as report.docx. A fourth is a macro-enabled .docm served as the non-macro document type. .docm has its own type, application/vnd.ms-word.document.macroEnabled.12. Labeling it as a plain document hides the macro from a user and from a filter.

  • application/zip is the container, not the document type. Send the wordprocessingml type.
  • application/msword is the old binary .doc type, not DOCX.
  • The MIME string is case-insensitive and still easy to truncate. A truncated subtype is a different type.
  • Content-Disposition filename should end in .docx if you want the OS association.

Frequently asked questions

Why not application/zip?

The file is a ZIP, and clients need the Open XML type to open it in a word processor. application/zip invites an unzip tool.

What is the exact type?

application/vnd.openxmlformats-officedocument.wordprocessingml.document.

How do I recognize the file?

It starts with PK, and it contains [Content_Types].xml and word/document.xml.

Is .doc the same?

No. Binary .doc is application/msword. It does not start with PK.