npm / docx
docx
What changed in docx 8 to 9, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-28.
14 breaking1 deprecations74 new APIs and options2 performance13 behavior and defaults1 tooling52 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initdocx 9148 changes
Breaking changes 12
No longer wraps its XML in an
<undefined>element.When zipping fails, toStream emits the failure on the stream's error event instead of causing an unhandled rejection.
A table with relativeVerticalPosition set to INLINE is now written in line with the text rather than floating.
The package now declares that Node.js 16 or later is required.
Table rows with no cells are omitted because Word can't open them.
A paragraph or table no longer type-checks as a paragraph's child.
Throws when a drawing is too large for Word to open.
Removes the empty WORKAROUND2 export, which was only needed by awesome-typescript-loader.
Removes the empty WORKAROUND3 export, which was only needed by awesome-typescript-loader.
Removes the empty WORKAROUND4 export, which was only needed by awesome-typescript-loader.
External styles are now merged with default styles, affecting generated document styling.
The list of supported highlight colors is now limited.
New APIs and options 70
Can now be set in paragraph styles, numbering levels, and document defaults, in addition to on a paragraph.
Adds a paragraph option for controlling the small space Word puts between East Asian text and an adjacent Latin letter.
Use ImagePatch with patchDocument to replace a picture's image in a template while keeping its size, position, text wrapping, and effects.
Read the theme of a Word document or template so a new document's styles can keep its fonts and colors.
Set trimPlaceholders to true to patch placeholders with spaces inside their braces, such as {{ name }}.
Use paragraph.with() to create a new paragraph from an existing one with some options changed.
Adds a diagonal-down border to table cells, allowing a header cell to be split.
Adds a diagonal-up border to table cells, allowing a header cell to be split.
Adds an entry for citing sources and listing them in a bibliography using Word's citation styles.
Adds an entry for embedding files as objects that open when double-clicked.
Marks the end of a part of a protected document that remains editable.
Marks the start of a part of a protected document that remains editable.
Embeds a file, such as a spreadsheet, as an object that opens when double-clicked.
Fits a run's text to a width.
Can set document properties, such as its title and author, when patching a document.
Makes a document read-only in Word or keeps parts editable, with an optional password.
Styles a section's line numbers.
Lets you choose what fills the space before table-of-contents page numbers, such as nothing or hyphens.
Create macro-enabled .docm documents with VBA code; the new docx/macros entry and a Word-saved vbaProject.bin are also supported.
Runs can use Word's Two Lines in One and Horizontal in Vertical through eastAsianLayout.
Restart a numbered paragraph's list with numbering: { restart: true }, without making up instance numbers.
patchDocument can now read a template from a stream.
Can receive note content directly instead of an identifier, adding the note to the document automatically.
Returns paragraphs and tables from HTML for use in sections and multiple document content locations.
Converts HTML into a paragraph's content for use in paragraphs and paragraph patches.
A paragraph numbering reference can now provide its own definition, which is added when the paragraph is written.
Accepts a numbering option so numbered and bulleted paragraphs in patches work correctly.
Adds document layout calculation matching Word, including page numbers, references, fields, and page contents.
Adds support for footnotes and endnotes in document patching.
Repeats template table rows for each row of supplied data.
Adds footnote and endnote properties to section options.
Adds a locked option to SimpleField.
Converts LaTeX math into editable Word equations, including common commands and environments, and returns components for mixing with hand-built math.
Adds fraction type selection for stacked, skewed, linear or barless fractions.
Adds control over whether integral limits are used.
Adds a component for constructing large mathematical operators used by LaTeX conversion and hand-built equations.
Adds literal handling to MathRun for representing literal mathematical content.
Adds script support to MathRun for constructing scripted mathematical text.
Adds style support to MathRun for controlling the presentation of mathematical text.
Adds control over whether summation limits are used.
Adds new data to charts created and styled in Word while preserving their appearance.
Adds a chart run that can be inserted where a document placeholder is located.
Adds native Word charts with many chart types, including combo, radar, bubble, stock, pie-of-pie, and bar-of-pie charts.
Adds matrices, cases, numbered aligned equations, and brackets made from arbitrary characters while preserving existing math imports.
Adds preset and custom SVG-path shapes, including diagrams, connectors, canvases, automatic layout, and richer text and fill options.
Adds text or picture watermarks behind every page, recognized by Word's Design > Watermark menu.
Images can now be cropped when generating documents.
ImageRun now supports run properties.
Adds drawing canvases with connectors and automatic layout for flowcharts, org charts, and swimlane diagrams.
Adds grouped shapes for composing multiple shapes as a unit.
Adds runs for inserting shapes into documents.
Documents now have a theme, configurable through the theme option for colors and fonts used across document elements.
Generated documents now emit word/commentsIds.xml with durable comment IDs using w16cid.
Comments now support replies.
Paragraph indentation now supports firstLineChars.
Numbering levels can now associate with a paragraph style.
Comments now support a resolved state.
Images now support tracked changes in generated documents.
Table look support was added for conditional table formatting.
The docx library now supports creating endnotes.
Track changes support has been extended with additional functionality.
Support was added for WPS text boxes.
Content Controls are now supported, enabling developers to use them in generated DOCX documents.
Paragraphs now support between borders, allowing developers to configure this border style.
FileChild is now exported for developers to use.
A math limit component is now available.
Documents can now be exported with multiple patches.
Numbering inherited from a paragraph style can now be disabled.
Patches present in a file can now be detected.
SVG images are now supported in documents.
Performance 2
Patching large documents now searches for placeholders in linear time, avoiding quadratic slowdowns while preserving paragraph order.
The browser bundle is about 29 KB smaller after switching zipping and hashing implementations and leaving out unused stream code.
Behavior and default changes 11
The theme now takes the theme's fonts for other scripts.
Cells added below a rowSpan cell now take its formatting and paragraph alignment.
A table's style can now supply its borders.
Bold and italic faces of a font are now embedded in generated documents.
Writes cell widths from columnWidths and applies Word's default cell margins for matching layout.
Can insert ChartRun instances into placeholders and resolve theme colors from a template's own theme.
Text can use the theme's heading or body font, allowing typography to change when the Word theme changes.
Table of Contents creation now supports cached data.
Footnotes now support lists and images.
Table of Contents creation has been extended with additional capabilities.
The system now returns which token has not been found, making missing-token errors more actionable.
Tooling 1
Documentation examples now run with this version, render documents beside editable code, provide completions and type errors, and allow .docx downloads.
Fixes and other changes 52
Now lays out repeated table properties, split rows with multiple line spacing, and overfull fixed-size text boxes as Word does.
The bundled HTML parser is updated to parse5 8.1.1, so docx/html reads HTML with the latest parse5 fixes.
Published types no longer add a global declaration for import.meta.glob, preventing duplicate identifier errors in projects that declare it themselves.
Images are written to the package as image1.png, image2.jpg, and so on instead of using a hash of their data, avoiding empty boxes in Word for the web.
Finds placeholders in link text, content controls, and text typed with Track Changes on, which were previously skipped without an error.
A text box of auto height is written 1in tall so WPS Office fits it to its text.
An image whose alt text has only a description now gets the empty name required by XML.
Word now shows Update Table on a table of contents written by docx.
Control characters disallowed by XML 1.0 are left out so they no longer produce documents Word can't open.
Using
style: "Caption"now gives captions Word's Caption style.Writes a half-inch default tab stop so tabs and list text line up in Pages.
Defines the TOC1 to TOC9 styles so LibreOffice keeps table-of-contents levels indented after updating the table.
Components made by another copy of docx, such as one bundled with a plugin, are written correctly.
Empty alt text is left out of wp:docPr so Word 2007 opens images.
An image's type is read from its data when it isn't provided.
An index entry field no longer scrambles the document in Word.
When page numbers come from docx/layout, a numbered heading's table of contents entry starts with its number.
A style's basedOn is omitted when it is the style's own id.
Rows below a merged cell are sized using the cell's margins.
Restart every level of a numbering instance, not only the first.
Each part of a page number field is written in its own run so it keeps the run's font.
Merged rows are kept together using TableRow keepNext.
Assigns unique drawing identifiers to inserted images so patched documents remain readable by Word.
Adds or reuses heading styles in templates so patched headings retain their intended formatting.
Writes specVanish from its own option instead of incorrectly deriving it from vanish.
External hyperlink fragments are now preserved in Word documents.
Supports writing a bookmark inside another bookmark.
Preserves embedded fonts when saving a document again.
Writes images and lists contained in endnotes.
Preserves paragraph and character styles supplied through externalStyles.
Makes frame width and height optional.
Calls super() once so ImageRun works under Turbopack.
Packing a document again now writes the same document.
Adds the separate field character to page references.
Inserts an inline bookmark with an identifier unused by the template.
Formats patched link text like its placeholder and adds relationships only where used.
Writes table-of-contents entries from document headings.
Bookmark numeric IDs are now allocated per document.
A comments part is written only when the document contains comments.
Style definitions no longer emit an implicit ListParagraph paragraph style.
Normal is now written as the default paragraph style so Pages draws math at its intended size.
Repeated document placeholders are now patched in reverse order.
Theme colors can be used for text, underlines, borders, shading, shapes, and page backgrounds.
Fixed an issue with bundling types, which may affect TypeScript consumers.
Embedded fonts now use sequential filenames.
Page size now correctly sets its code.
Passes the characterSet parameter to createRegularFont when generating font tables.
First-level numbering now allows zero as the starting number.
Multiple splits within a single run are now handled correctly.
XML is pre-encoded as UTF-8 to prevent surrogate pair corruption in JSZip.
Numbered item references are now exported, making that reference available to developers.
Corrects the limit location value of MathIntergral.
docx 89 changes
Breaking changes 2
Document Patcher replaces the Template feature.
Typing for File's Children is stricter.
Deprecations 1
The template dotx feature is deprecated.
New APIs and options 4
Comments now accept children.
Support for different languages is added.
Multiple override levels are supported.
Positional tabs are supported.
Behavior and default changes 2
Spacing of East Asian text and numbers is automatically adjusted.
Hyperlinks now work on images.