Home · Docs · Import + Export · Export as Word (.docx)

Export as Word (.docx)

A real Word document built from your Markdown. Headings as Word heading styles, native Word tables, images downloaded and embedded so the file is self-contained.

Word export builds a real .docx from your Markdown — not a wrapper around the source text. The result opens cleanly in Microsoft Word, Apple Pages, and Google Docs.

kyoto-trip.docx — Word
HomeInsertLayoutReferencesView

Kyoto, days 1-3

We land in Kyoto on the 12th and have three full days before Osaka.

DayMorningAfternoon
Day 1ArashiyamaTenryū-ji
Day 2Fushimi InariNishiki
fushimi.jpg

How to export

Doc toolbar → download iconWord (.docx). The browser downloads <title>.docx.

Under the hood

We use the docx JavaScript library, which builds a real Word XML document in the browser. The pipeline:

  1. Tokenize: marked.lexer() parses your Markdown into a structured token tree
  2. Walk: for each top-level token, build a Paragraph (or set of paragraphs for lists, tables, etc.)
  3. Inline tokens: bold, italic, strikethrough, code, links become TextRun and ExternalHyperlink instances
  4. Images: each image URL is fetched as bytes, optionally normalized, then embedded as an ImageRun inside the paragraph
  5. Pack: the document tree gets serialized with Packer.toBlob() and downloaded

The conversion is entirely client-side — no quota, no server call, works offline (except for the image fetches, which need network).

What survives the conversion

MarkdownWord output
H1 through H6Word’s Heading 1 through Heading 6 styles
Title (synthesized if needed)Heading 1 at the top
ParagraphsDefault style
Bold, italic, strikethrough, codeBold, italic, strikethrough, monospace runs
LinksReal Word hyperlinks with their target URL
Bullet lists, numbered listsWord’s native list styles, nested levels preserved
TablesNative Word tables with the header row marked
BlockquotesIndented paragraphs (Word’s blockquote doesn’t exist as a distinct style)
Fenced code blocksSingle-spaced monospace paragraphs
Horizontal rulesWord’s horizontal rule paragraph
Images (with or without width / alignment)Embedded ImageRun with the width and alignment carried through
Hex color swatchesThe hex literal as text

Image handling — self-contained

The big win over Markdown export: images are downloaded and embedded inside the .docx, not left as URL references. The file is self-contained — you can email it, archive it, or attach it to a ticket and the recipient sees the images even without internet access.

Each ![alt](url) becomes:

  1. A fetch(url) to pull the image bytes
  2. An ImageRun instance wrapping those bytes
  3. A paragraph containing the image (with the width and alignment from the original)

If an image fetch fails (network error, CORS, image deleted), it’s skipped silently — the export proceeds without it.

What’s lost or transformed

Markdown / sweetdocs featureWord result
Sweetdocs theme colorsReplaced by Word’s default styling
Inline HTML (other than <img>)Dropped — only image HTML is interpreted by the converter
Comment anchor spansDropped (just the visible text remains)
Hex color swatchesVisible as text only; no color chip
Live links between docs (/docs/...)Kept as their literal URL
Code-block language hintThe hint is dropped at the Word level (Word doesn’t model fence languages); the content stays monospace

When to use Word export

Compared to PDF

PDF and Word are both “produces a finished document” exports, but:

WordPDF
Recipient can editYesNo (without OCR tools)
Heading navigationYes (Word’s outline)Yes (PDF bookmarks, when supported)
File sizeLarger (embedded images)Varies (depends on image compression)
Exact visual reproductionNo (Word reflows)Yes
Generation pathClient-side, instantThrough the browser print dialog

Use Word when the document will be edited; use PDF when the document is final.