Introduction
.doc is the extension of
Microsoft Word’s binary
documents, the default format until Word 2007 replaced it with
DOCX. Billions of these files still
exist, and every current word processor can open them.
The format changed several times. Word for Windows 1.x and 2.0 wrote a plain binary
file. Word 6.0 (1993) and Word 95 moved the document into a compound file, a small file
system inside the file. Word 97 kept the compound file but changed the document inside
it, adding Unicode text, and Word 2000, 2002 and 2003 kept the Word 97 format. Word for
MS-DOS and early versions of Word for the Mac also used .doc for formats of
their own.
Variations
| Format | Variation | About | Open |
|---|---|---|---|
.DOC | Word 6.0 and 95 document | Word 6.0 and 95 documents: single-byte text in one compound file stream. | Open |
.DOC | Word 97–2003 document | Word’s binary document from Word 97 to 2003: streams in a compound file. | Open |
.DOC | Word for Windows 1.x and 2.0 document | Word 1.x and 2.0 documents: a plain file of single-byte text and tables. | Open |
Word for Windows 1.x and 2.0
The format of Word for Windows 1.x and 2.0: a plain file, with no compound file, that starts with a File Information Block and keeps single-byte text.
The first two bytes are 9B A5 in Word 1.x files and DB A5
in Word 2.0 files.
Word 6.0 and 95
The format of Word 6.0 and Word 95 (Word 7). Text is stored in single-byte characters of a Windows code page, and all of the document, its text, formatting and tables, is in one stream.
The file is a compound file holding a WordDocument stream, which starts
with the File Information Block. Its first two bytes, wIdent, are
0xA5DC, and nFib is 101 for Word 6.0 or 104 for Word 95.
There is no 0Table or 1Table stream.
Word 97 to 2003
The format of Word 97, 2000, 2002 and 2003, and the one most .doc files
use. Text can be Unicode, and the tables that describe the document, such as the
piece table, styles and fonts, move to a separate table stream.
The WordDocument stream starts with a File Information Block whose
wIdent is 0xA5EC and whose nFib is 193
(0x00C1). The compound file also holds a table stream named
0Table or 1Table.
Files named .doc that are not Word binary
Many .doc and .dot files are something else, mostly from programs
that used the extension for readme and manual files. The explorer looks at the content, not
the name. A file that starts with {\rtf is a
Rich Text Format document: it is read as RTF,
with its text, bold and italic, headings, tables, notes, headers, document information,
font and colour tables and pictures stored as hex or raw bytes (PNG, JPEG, EMF, WMF, DIB).
A file with no Word or RTF signature that reads as text (a few NUL bytes at the very end are
allowed) is shown as plain text, in its encoding. A file
that is neither is shown as bytes.
Not described
This page and its variant pages cover the structures the explorer reads. It is not complete. The ratings stay partial.
Known, not yet covered
- Reference and viewer: Word 2 pictures and drawing objects. The Word 1.x and 2.0 character properties hold the picture position in a fixed layout that is not interpreted; the viewer shows a label.
- Reference and viewer: the style sheet of Word 1.x and 2.0 and the property codes of those versions beyond the ones that build tables (the viewer ignores them).
- Reference and viewer: Word 6 and 95 drawing objects
(
[drawing]), and floating Word 97 shapes that are not pictures (lines, boxes, WordArt, text-box frames): shown as a label. - Viewer: list numbering text (the viewer writes
1.for every numbered level and-for bullets, not Word’s own numbers), nested tables, fonts, sizes, colours, underline, alignment and indents (Markdown has none), form fields, tracked-change authors and dates, page layout of sections, and the contents of embedded objects (listed, not opened). - Viewer: encrypted files (RC4, CryptoAPI) and obfuscated ones are named as encrypted and their text is not shown; no password is ever asked for.
- Reference: the full table of Word 97 property codes and the complete
Dopdocument-properties record are described only in part; the [MS-DOC] specification has them. - Viewer: macros are flagged (a VBA project or macro text) and never run or decoded.
- Viewer: RTF read from a
.docname shows text, tables and pictures; shapes, text boxes, field instructions, list numbering and styles of the RTF are skipped.
Unknown
- Reference: no Microsoft document describes Word 1.x, 2.0, 6.0 and 95 property codes. The tables here come from real files and from published readers; codes not seen in the files checked (83 Word 2 and 57 Word 6 files) are unverified.
- Reference: the Word for Mac variants of the format (the byte order and the Mac character set of Word 5 files) are not covered: no such file was available.
Links
Software
- Microsoft Word – Microsoft’s word processor, which opens and saves both versions of .doc (Windows, macOS, web, mobile)
- LibreOffice Writer – free office suite’s word processor, which opens and saves .doc (Windows, macOS, Linux)
- Google Docs – online word processor that imports and exports .doc (web browsers)
- Apple Pages – Apple’s word processor, which imports .doc (macOS, iOS)
Developers
- Apache POI – library for Office files, reading Word documents through its HWPF classes (Java)
Reference
- [MS-DOC]: Word (.doc) Binary File Format – Microsoft’s full specification of the Word 97–2003 format
- [MS-CFB]: Compound File Binary File Format – Microsoft’s specification of the compound file container