Word Open XML Document is a document format commonly identified by .docx. Use the listed signatures, MIME types, and structure notes to validate files beyond the extension.
Do not trust the extension alone. Check the MIME type, the first bytes such as 50 4B 03 04, and format-specific structure when possible.
Container formats and damaged files can share the same opening bytes, so deeper validation may be required for production upload, preview, or conversion flows.
Detection example
SIGNATURE = bytes.fromhex("504b0304")
OFFSET = 0
def is_docx(path: str) -> bool:
with open(path, "rb") as f:
f.seek(OFFSET)
head = f.read(len(SIGNATURE))
return head == SIGNATURE
const SIGNATURE = [0x50, 0x4b, 0x03, 0x04];
const OFFSET = 0;
// bytes: a Uint8Array / Buffer holding the start of the file
export function isDocx(bytes) {
return SIGNATURE.every((byte, i) => bytes[OFFSET + i] === byte);
}
package fileid
import "bytes"
var isdocxSignature = []byte{0x50, 0x4b, 0x03, 0x04}
const isdocxOffset = 0
func IsDocx(b []byte) bool {
end := isdocxOffset + len(isdocxSignature)
if len(b) < end {
return false
}
return bytes.Equal(b[isdocxOffset:end], isdocxSignature)
}
Word Open XML Document is used for data exchange, imports, exports, parser testing, and validation workflows. Encoding, delimiters, versions, and container structure often change implementation behavior.
Common detection mistakes
The .docx extension alone does not prove the file contents. Upload and conversion flows should combine extension, MIME type, leading bytes, and format-specific structure checks.
Word Open XML Document can start with signatures such as 50 4B 03 04, but related containers and damaged files may require additional validation.
Security notes
Document formats may include scripts, attachments, macros, or external references. Sandbox previews and conversions, and avoid opening untrusted files directly.
Using samples
11 samples help test leading-byte detection, parser errors, upload limits, and download behavior.
Blue Sky DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Flower Garden DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Navy Blue Sky DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Nature of the Sky DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Sky Landscape DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Starry Sky DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Blue Night Sky DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Hibiscus Flower DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Arctic Sky DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Sunset Rays DOCX is a Word Open XML Document sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
NASA Blue Marble DOCX is a Word Open XML Document sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.
What is the magic number (file signature) of Word Open XML Document?
Word Open XML Document files begin with the byte signature 50 4B 03 04 ("PK.."). Detect the format by reading these leading bytes rather than trusting the file extension alone.
What is the MIME type of Word Open XML Document?
The MIME type for Word Open XML Document is application/vnd.openxmlformats-officedocument.wordprocessingml.document.
What file extension does Word Open XML Document use?
Word Open XML Document files use the .docx extension. The extension is a convention only and does not guarantee the file contents, so combine it with signature and structure checks.