Utilo

DOC MIME Type – Free, Online, Private

application/msword is the type for a legacy binary Word .doc file. A .docx package uses the Open XML type instead.

What .doc is

The binary Word format used before Office Open XML is a Compound File Binary document. It starts with the OLE signature D0 CF 11 E0 A1 B1 1A E1, not with PK. IANA registers application/msword for .doc. That type is not the DOCX type, and it is not text/html, even though Word used to save 'web pages' and people renamed them to .doc. A real binary document has the OLE header. WordprocessingML XML saved with a .doc extension is a third thing and is a source of corrupt-file errors when a client trusts the extension.

IANA registers application/msword. The media type is application/msword. Extensions that use it on this page: .doc. 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/msword

What sends application/msword: Send application/msword only when the bytes are a binary .doc. If you can convert to .docx or PDF, do that and send the type of the result. New documents should not be created in this format. Keep the type available for downloads of files you already have. Set a filename ending in .doc. Do not add a charset. The OLE container is binary. Text inside uses encodings the format defines, not an HTTP charset parameter. The file on disk is still .doc. Once the response exists, a client trusts application/msword, not the filename. If a converter produces DOCX, change the extension, the magic, and the Content-Type together. Leaving application/msword on a PK body is a file Word will try to repair. Leaving the Open XML type on an OLE body does the same in the other direction.

Content-Type for .doc

Send application/msword 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/msword

nginx, Apache, and Express

These snippets map .doc to application/msword. 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 .doc 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/msword          doc;
ApacheAddType application/msword .doc
Expressimport express from "express";

const app = express();
app.use(express.static("public", {
  setHeaders(res, filePath) {
    if (filePath.endsWith(".doc")) {
      res.setHeader("Content-Type", "application/msword");
    }
  },
}));

Pitfalls for application/msword

Pitfalls that show up for application/msword, and not for a neighboring type with a similar extension: The common bug is a server map that sends application/msword for both .doc and .docx. DOCX then fails to open or opens with a repair dialog. Split the mappings. Another bug is an HTML file with a .doc name, which Word will open and which a browser may treat as a download of a word processor file. Sniff the OLE signature if you accept uploads. Another is macros in the binary format, which this type does not distinguish. Treat untrusted .doc as active content. Another is a types file that maps .doc to application/octet-stream after a partial edit, so the association is lost.

  • application/msword is not the DOCX type. DOCX starts with PK and uses the wordprocessingml type.
  • The OLE signature D0 CF 11 E0 is shared with old .xls and .ppt. The extension and the streams inside tell them apart.
  • application/vnd.ms-word is not the registered spelling. application/msword is.
  • Do not send this type for RTF. RTF is application/rtf and is text.

Frequently asked questions

Which type is a binary .doc?

application/msword. The Open XML .docx type is a different registration.

What does the file start with?

The OLE bytes D0 CF 11 E0 A1 B1 1A E1. A file that starts with PK is not this format.

Should new documents use this?

No. Write .docx or PDF. Keep application/msword for legacy downloads.

Does the type mean the file has no macros?

No. Binary Word documents can contain macros. Treat untrusted uploads as active content.