What survives a .docx round-trip in a browser editor
Updated 2026-08-09
A .docx file is a ZIP archive of XML parts — document body, styles, numbering definitions, headers, media — and no browser editor edits that XML in place. What actually happens is two lossy conversions: the document becomes HTML on the way in, gets edited as HTML, and is re-authored as a brand-new .docx on the way out. So the only question that matters is: what survives both hops? Vague answers ("most formatting is preserved") are useless. This is a precise inventory for the editor on this site, produced by pushing a deliberately over-formatted document through the real pipeline and comparing the two ends.
The pipeline is mammoth.js (1.12) for import, a contentEditable surface for editing, and the docx package (9.x) for export. Each stage has deliberate, documented limits. Knowing them tells you when this tool beats finding a machine with Word installed — and when it will quietly eat your tables.
Two conversions, not one edit
The import step uses mammoth, whose entire design philosophy is converting to semantic HTML rather than visually faithful HTML. It maps Word's named styles to markup — the Heading 1 style becomes an h1 element, list paragraphs become ul/ol, bold runs become strong — and it intentionally discards presentation: font families, sizes, colors, highlighting, and paragraph alignment are simply not emitted. That is a feature in mammoth's intended use case (extracting clean, publishable HTML from Word documents), but it means visual fidelity was never part of the contract.
The export step is a whitelist that mirrors the editor toolbar: headings 1–4, paragraphs, bold, italic, underline, single-level bulleted and numbered lists, hyperlinks, line breaks, and blockquotes (rendered as a one-third-inch left indent). Any HTML element outside that list falls through to a default rule: its text content is collected into a plain paragraph, and its structure is discarded. Nothing errors; the text just arrives flat.
The survival table
| Word feature | Visible in the editor? | Survives export to .docx? | Notes from the test run |
|---|---|---|---|
| Headings 1–4 | Yes | Yes | Heading 5–6 import as h5/h6 but export as body text |
| Bold, italic | Yes | Yes | Round-tripped intact |
| Underline | No — dropped at import | n/a | mammoth omits underline by default; underline applied inside the editor does export correctly |
| Strikethrough, subscript, superscript | Yes | Text only | Formatting stripped on export; the characters remain |
| Hyperlinks | Yes | Yes | Exported as real hyperlinks, underlined |
| Bulleted / numbered lists | Yes | Single level only | Nested levels flatten |
| Tables | Yes | Text only | Our 2x2 test table exported as one paragraph reading R1C1R1C2R2C1R2C2 |
| Images | Yes (inlined as base64) | No | Silently dropped by the .docx export |
| Font, size, color, highlight, alignment | No | No | Discarded at import, before you ever see them |
| Headers and footers | No | No | A test doc with both imported as body text only |
The word to notice in that table is "silently." The dangerous failure mode is not the formatting that vanishes when the file opens — you see that immediately. It is tables and images, which look perfectly healthy in the editor and are only lost at export. If your document contains either, decide up front whether you can afford that (or use the HTML escape hatch below) before you spend twenty minutes editing.
Why the formatting goes away: style names, not layout
Mammoth reads the style names attached to Word content, not the visual result. A consequence worth knowing: import quality depends on how the original document was authored. A document using real Heading styles produces clean h1/h2 structure. A document where someone faked headings by manually bolding and enlarging text imports as bold body paragraphs, because that is what the underlying markup says. Garbage styles in, flat HTML out — the tool cannot recover intent the author never encoded.
On the way out, the docx package builds a fresh document from scratch — new style definitions, new numbering tables, new everything. The export is not a patch of your original ZIP; it is a re-authoring. Two practical consequences: first, the exported file uses default Word styling, so it will not match your organization's template even for features that survived; second, your original file on disk is untouched, so nothing here is destructive as long as you do not overwrite the original with the export.
The HTML escape hatch
There is one asymmetry worth exploiting. The editor's HTML export writes the live editor content verbatim — and since mammoth imported your tables as real table markup and your images as embedded base64, both survive perfectly to HTML even though neither survives to .docx. So if you loaded a table-heavy document just to fix some wording, export HTML and you keep the structure. The HTML file opens in any browser and pastes back into Word or Google Docs with tables intact. It is the difference between a lossy round-trip and a one-way conversion done deliberately.
Import (mammoth output, shown in editor): <table><tr><td><p>R1C1</p></td><td><p>R1C2</p></td></tr>...</table> <p><img src="data:image/png;base64,iVBORw0KGgo..." /></p> Export to .docx (re-imported to inspect): <p>R1C1R1C2R2C1R2C2</p> - table flattened, image gone Export to HTML: identical to the import - table and image preserved
When the round-trip is fine, and when to close the tab
- Good fit: fixing typos, renaming, or rewording a prose document on a machine without Office — the whole edit happens in the page.
- Good fit: drafting a letter, statement, or plain report from scratch and delivering it as .docx to someone who expects Word format.
- Good fit: extracting clean text or clean HTML from a heavily formatted document — mammoth's semantic conversion is genuinely better at this than copy-paste from Word.
- Bad fit: contracts, invoices, or anything where tables carry the meaning — the structure will not survive .docx export.
- Bad fit: documents on letterhead or brand templates, image-bearing documents, and anything using tracked changes or comments, which this pipeline does not carry.
The underlying trade is clear once you see it: this editor treats a .docx as a container for structured text, not as a page-layout artifact. For the large class of documents that really are just structured text, the round-trip loses nothing you care about. For the rest, use the HTML export, or make the edit in LibreOffice — knowing which case you are in before you start is the whole game.
Questions people ask
Why does the exported file look different in Word even where the content survived?
The export builds a brand-new document with default styles rather than patching your original file. Headings, lists, and links survive as structures, but they render in Word's defaults, not your original template's fonts and spacing.
Why did my underlines disappear before I even edited anything?
That is the import step: mammoth does not emit underline formatting by default, so it is gone the moment the document renders in the editor. Underline you apply inside the editor is exported correctly — the loss is one-directional.
Is there any way to keep my tables?
Not through the .docx export, which flattens each table into a single paragraph of run-together cell text. The HTML export preserves tables and images exactly as imported, and pastes back into Word or Google Docs with structure intact.
What does the browser's network tab show while a document is being converted?
No request carrying your document. The .docx is unpacked, edited, and re-generated entirely in your browser tab; there is no server-side processing.