file in abyss
フォーマット一覧へ戻る

Document

DOCX Word Open XML Document

Microsoft Wordで広く使われるOffice Open XML文書。実体はZIPパッケージで、word/document.xmlなどを含みます。

Extensions .docx
MIME application/vnd.openxmlformats-officedocument.wordprocessingml.document

マジックナンバー

ファイルを解析
オフセット 0 ZIP local file header
50 4B 03 04
PK..

構造

  1. ZIP container
  2. [Content_Types].xml
  3. _rels/.rels
  4. word/document.xml

注意点

  • ZIPと同じ先頭シグネチャなので、DOCX判定には内部エントリ名の確認が必要です。

判定コード例

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

実践的な使い方

ユースケース

Word Open XML Document はデータ交換、インポート/エクスポート、パーサのテスト、検証ワークフローで使われます。エンコーディング・区切り文字・バージョン・コンテナ構造が実装の挙動を変えることがあります。

よくある判定ミス

  • .docx という拡張子だけではファイルの中身を保証できません。アップロードや変換の処理では、拡張子・MIMEタイプ・先頭バイト・形式固有の構造チェックを組み合わせるべきです。
  • Word Open XML Document は 50 4B 03 04 のようなシグネチャで始まりますが、関連するコンテナや破損ファイルでは追加の検証が必要になる場合があります。

セキュリティ上の注意

文書形式はスクリプト・添付・マクロ・外部参照を含むことがあります。プレビューや変換はサンドボックス化し、信頼できないファイルを直接開かないでください。

サンプルの活用

11 個のサンプルで、先頭バイト判定・パーサのエラー・アップロード上限・ダウンロード挙動をテストできます。

サンプルファイル

11 / 11 files
Sample Traits Size Source / license / SHA-256
Doc

Blue Sky DOCX

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.

01-blue-sky.docx
Type Sample
1.4 KB
SHA-256 ecdeb8876f29896e26ab2291c275b7dda500eb769669fbdaa5b3e16123eb7bb0
Download
Doc

Flower Garden DOCX

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.

02-flower-garden.docx
Type Sample
1.5 KB
SHA-256 aa9203da7c21b43c532ac66622a34ce7952efbc62fb49cab0cf7d53f685c276d
Download
Doc

Navy Blue Sky DOCX

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.

03-navy-blue-sky.docx
Type Sample
1.5 KB
SHA-256 165ba457ca04d0963c0f8779cc1aafb8eca9dd87a5c996d1c0a62e6f845248fe
Download
Doc

Nature of the Sky DOCX

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.

04-nature-sky.docx
Type Sample
1.6 KB
SHA-256 8a5ba5754bee861941c74d490604a26e53a156097574b4492fbd62e20c40e8b6
Download
Doc

Sky Landscape DOCX

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.

05-sky-landscape.docx
Type Sample
1.6 KB
SHA-256 cb45942888fa84fe6c1f5d06023f317dcee8a0271ba333947a1da78aef77b1bf
Download
Doc

Starry Sky DOCX

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.

06-starry-sky.docx
Type Sample
1.7 KB
SHA-256 febd4887b583dfc0ab0f253fb2056ec0f6a16e7fc44f616ba35d926e0185c89b
Download
Doc

Blue Night Sky DOCX

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.

07-blue-night-sky.docx
Type Sample
1.7 KB
SHA-256 1663e4dc8e2ab1f0f6edb16ff0bbd55fd42abbabfa0bbb78e31e4e9e8333becc
Download
Doc

Hibiscus Flower DOCX

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.

08-hibiscus-flower.docx
Type Sample
1.8 KB
SHA-256 a77a5e581defd26e8dce364ee2de805ae26e5da346c76a5f651c8b51c2774111
Download
Doc

Arctic Sky DOCX

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.

09-arctic-sky.docx
Type Sample
1.8 KB
SHA-256 2cd4ca0ad25fb60fca45a22f258c6192c86ddb0c692f2e8456774aa7d877cbb7
Download
Doc

Sunset Rays DOCX

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.

10-sunset-rays.docx
Type Sample
1.9 KB
SHA-256 c84d64f4acb2619f46470635e9297e70176651cfbb11506c698bee85d03cbb03
Download
Doc

NASA Blue Marble DOCX

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.

nasa-blue-marble-2012-east.docx
Type Sample
2.1 KB
SHA-256 b2cdfa34dc8f4c1c102ade1829c7cb322bbd2c6e4fa5358c9c44f5ed992abd27
Download

よくある質問

Word Open XML Document のマジックナンバー(ファイルシグネチャ)は?

Word Open XML Document ファイルはバイトシグネチャ 50 4B 03 04 ("PK..") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。

Word Open XML Document のMIMEタイプは?

Word Open XML Document のMIMEタイプは application/vnd.openxmlformats-officedocument.wordprocessingml.document です。

Word Open XML Document の拡張子は?

Word Open XML Document ファイルは .docx 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。

関連フォーマット