DOCX

Links

External hyperlinks, bookmarks, and cross-references in Word documents

Add navigation to your documents with hyperlinks and bookmarks.

Link to external URLs:

{
  "sections": [
    {
      "children": [
        {
          "paragraph": {
            "children": [
              {
                "text": "Visit example.com",
                "hyperlink": { "link": "https://example.com" },
                "underline": { "type": "single" },
                "color": "0563C1"
              }
            ]
          }
        }
      ]
    }
  ]
}

Link to bookmarks within the same document using hyperlink with anchor:

{
  "sections": [
    {
      "children": [
        {
          "paragraph": {
            "children": [
              {
                "text": "Go to Introduction",
                "hyperlink": { "anchor": "section-intro" },
                "color": "0563C1"
              }
            ]
          }
        }
      ]
    }
  ]
}

Bookmarks

Define a bookmark with the bookmark child, placed inline around the text it marks:

{
  "sections": [
    {
      "children": [
        {
          "paragraph": {
            "children": [
              {
                "bookmark": { "name": "section-intro", "wrap": ["Introduction"] }
              }
            ]
          }
        }
      ]
    }
  ]
}

wrap is the anchored document content the bookmark range wraps (inline runs/text).

PropertyTypeDescription
namestringBookmark name (the reference handle)
wrap(string | RunOptions)[]Anchored text the bookmark wraps
colFirstnumberFirst column of a table-cell scope
colLastnumberLast column of a table-cell scope
displacedByCustomXml"before" | "after"Displacement vs. a sibling customXml

Explicit markers (advanced)

For ranges that span paragraphs or tables, or to continue ids from an existing document, author the markers explicitly. The bookmarkStart and bookmarkEnd must share one id:

import { generateDocument } from "@office-open/docx";

await generateDocument({
  sections: [
    {
      children: [
        {
          paragraph: {
            children: [
              { bookmarkStart: { name: "section-intro", id: 0 } },
              "Introduction",
              { bookmarkEnd: 0 },
            ],
          },
        },
      ],
    },
  ],
});

Use bookmarks with hyperlink (using anchor) for cross-referencing within a document. The anchor property references bookmark names.

Screen Tips

Add a tooltip that appears on hover:

{
  "sections": [
    {
      "children": [
        {
          "paragraph": {
            "children": [
              {
                "text": "Example Link",
                "hyperlink": { "link": "https://example.com", "tooltip": "Click to visit Example" },
                "color": "0563C1"
              }
            ]
          }
        }
      ]
    }
  ]
}
Copyright © 2026