Free add-on for Pandoc

MDZip for Pandoc

Turn .mdz files into Word, EPUB, web pages and PDF with Pandoc, pictures included, and turn Word and Markdown files into .mdz.

Windows, macOS and Linux · also a GitHub Action · Install steps

Download this page as .mdz

MDZip for Pandoc lets you...

  • Turn an MDZip (.mdz) file into Word, a web page, an e-book (EPUB), PDF or any other format Pandoc writes, with its pictures included
  • Combine a document split over several files into one Word file, with the links between them still working
  • Turn a Word file or a Markdown file and its pictures into an .mdz

It's a free add-on for Pandoc, the document converter many writers and publishers already use. Pandoc does the converting; mdzip-pandoc teaches it to read and write .mdz. Everything runs on your own computer.

Install

  1. Install Pandoc, version 3 or later, if you don't have it yet. It runs on Windows, macOS and Linux.
  2. Download mdzip-pandoc-<version>.zip from the latest release and unzip it somewhere you'll find it again.

That's all. The folder holds mdz.lua, the file you give Pandoc, and everything it needs. Keep the files in it together.

Convert an .mdz

Open a terminal in the folder with your file, and give Pandoc the path of mdz.lua with -f ("from"). The name of the output file picks the format:

pandoc -f mdzip-pandoc/mdz.lua guide.mdz -o guide.docx
pandoc -f mdzip-pandoc/mdz.lua guide.mdz -o guide.epub
pandoc -f mdzip-pandoc/mdz.lua guide.mdz -s --embed-resources -o guide.html

The pictures come from inside the .mdz, so they end up in the Word file, the e-book or the web page. The title, author and language come from the file too. PDF needs a PDF program Pandoc can use, such as a LaTeX installation; see Pandoc's manual.

Several files as one Word document

An .mdz can hold a document split over several files, such as a main page that links to one file per chapter. Add +combine to make them one document:

pandoc -f mdzip-pandoc/mdz.lua+combine+pagebreaks guide.mdz -o guide.docx
  • The chapters come in the order the main page links to them.
  • Links between them become links inside the Word file, so a link to "Installing on Windows" in another chapter still goes there.
  • +pagebreaks starts each chapter on a new page. Leave it out to run them together.
  • Files nothing links to are left out, and Pandoc says which. Add +orphans to put them at the end.

Without +combine, only the main page is converted, and Pandoc says how many files it left out.

Word styles that travel with the file

The same table in Word, twice: on the left with Pandoc's own styles, a line under the header only; on the right with the styles carried in the .mdz, grid lines and a grey header row

Pandoc takes Word's look (fonts, headings, tables, page size and margins, headers and footers) from a reference document: any Word file or Word template (.dotx) whose styles you've set up the way you want. An .mdz can carry its own, so everyone who converts it gets the same look.

  1. Make the reference document. Start from Pandoc's, pandoc -o reference.docx --print-default-data-file reference.docx, open it in Word and change its styles, or use a template you already have.

  2. Add it to the .mdz, for example as styles/reference.docx, and name it in the file's manifest.json:

    "pandoc": { "referenceDoc": "styles/reference.docx" }
  3. Convert with -t mdzip-pandoc/docx.lua ("to"), the Word writer that uses it:

    pandoc -f mdzip-pandoc/mdz.lua guide.mdz -t mdzip-pandoc/docx.lua -o guide.docx

Only the styles and page setup are used, never the reference document's text or macros. A --reference-doc you give on the command line still wins. Other MDZip apps keep the setting and the file when they save the .mdz.

The grid-tables example carries the reference document in the picture above.

Make an .mdz

Give Pandoc the path of mdz.lua with -t ("to") instead, and name the output .mdz:

pandoc report.docx -t mdzip-pandoc/mdz.lua -o report.mdz
pandoc notes.md -t mdzip-pandoc/mdz.lua -o notes.mdz

The pictures go inside the .mdz: the ones in the Word file, and the ones a Markdown file points to on your computer. Pictures on the web stay links. The result opens in MDZip Studio, the VS Code and Obsidian plugins and the web editor, and passes mdz validate.

On GitHub

mdzip-pandoc is also a GitHub Action, for turning .mdz files into web pages or Word files whenever you push. It can build a whole website from a folder of .mdz pages, with a sitemap and link previews: mdzip-pages-example is one, published on GitHub Pages. See the Action's settings.

Good to know

  • It needs Pandoc 3 or later. It's tested with Pandoc 3.13 on Windows, macOS and Linux.
  • It reads Markdown the way MDZip editors show it (CommonMark, with Pandoc's extras such as footnotes and math). For Pandoc's own Markdown, with citations and captioned figures, add +pandoc: -f mdzip-pandoc/mdz.lua+pandoc.
  • Raw HTML passes through. HTML inside the document reaches HTML output unchanged, as with Pandoc's own readers. For an .mdz from someone you don't trust, add -raw_html (-f mdzip-pandoc/mdz.lua-raw_html): it drops raw HTML, event handlers such as onclick, and javascript: links.
  • A file with separate documents (a "project" .mdz, like a folder of notes) is converted one document at a time: Pandoc converts the main one and says how many it left out.
  • Some things need extra programs. SVG pictures in Word need rsvg-convert, and Mermaid diagrams stay as code unless you add a Mermaid filter to Pandoc.
  • A damaged .mdz stops Pandoc with an MDZip error code, such as ERR_ZIP_INVALID, instead of a half-converted file.

More

This page renders from pandoc.mdz (MDZip, ~30 KB, updated 2026-11-17) — one self-contained file. Download it, open it in the web editor, or read how these pages are made. Built with @mdzip/renderer.