| Pandoc | |
|---|---|
| Software | |
| Official project | John MacFarlane · Pandoc |
| Interface | Terminal and command line |
| Platforms | Windows, macOS, Linux and others |
| License | Open-source GPL |
| Basic example | Markdown → DOCX |
| PDF output | Requires a separate PDF engine such as LaTeX |
Choose an official installation method
Pandoc is a command-line tool that converts document files between formats. Instead of opening an editor window, you run it in a terminal with input and output filenames. It can prepare a document for Word, but does not reproduce every detail of page layout.
Use the official installation guide in the infobox and choose the method for your OS.
| Environment | Basic official installation choices |
|---|---|
| Windows | Official MSI installer; check ZIP and PATH conditions if using a separate folder |
| macOS | Official installer package or a documented package manager |
| Linux | Distribution package or official release matching your CPU |
The official Windows installer adds the executable location to PATH. Extracting a ZIP and making pandoc discoverable in a terminal are separate steps. Multiple installation methods can leave different versions installed, so first identify the method you are using.
Check the version and open the document’s folder
After installation, open a new PowerShell or Command Prompt and enter this command. The same version command works in a Mac or Linux terminal.
pandoc --version
Version output means the command was found. If it is not recognized, check installation and PATH, then open a new terminal.
For your first conversion, use the folder containing the input document as the working directory. Navigate to it in the terminal, or open that folder in an editor and use its terminal. VS Code can edit and preview documents but is not required to run Pandoc.
Pandoc uses UTF-8 for text input and output. Save Markdown as UTF-8, and do not assume PowerShell and Command Prompt have identical command or encoding settings. For Korean text display in an older Windows Command Prompt, also check the official getting-started guide’s UTF-8 conditions.
Make your first Word document from Markdown
Create a small original sample.md in an empty practice folder.
# Preparation document
## Checklist
- Check the filename
- Open the output document
| Item | Status |
| --- | --- |
| Materials | Ready |
Run this command from the input folder. If sample-check.docx already exists, choose a new name to avoid overwriting it.
pandoc -f markdown -t docx "sample.md" -o "sample-check.docx"
| Part | Meaning |
|---|---|
-f markdown | Read the input as Markdown |
-t docx | Write Word DOCX output |
"sample.md" | Actual input filename |
-o "sample-check.docx" | Separate output filename |
Quote filenames and paths containing spaces. The original .md and output .docx are different files. After running the command, open the DOCX in an actual editor and check the heading, list, table and text, including any Korean text you added. Creating an output file does not establish that all formatting is identical.
Check images, the working directory and input paths
A Markdown image reference such as images/sample.png needs the actual image file. Pandoc’s default resource search is based on the current working directory. Providing an absolute document path from another folder can therefore change where it looks for images.
Begin by converting from the document’s folder and checking images in the DOCX. If you must run from another folder, specify image search paths with the manual’s --resource-path. Separate multiple paths with semicolons on Windows and colons on Mac or Linux. When specifying this option, explicitly include the current directory if it also needs to be searched.
After changing an image path or filename, convert to a new output name and compare again. Archive referenced images together with the .md file.
Convert Word back to Markdown
To move a DOCX you created into Markdown, reverse the input and output formats. For a document containing images, also extract media into a separate new folder.
pandoc -f docx -t markdown "sample-check.docx" -o "restored.md" --extract-media="restored-assets"
Choose new names if restored.md or restored-assets already exists. A document without images may have no media to extract. For images, check both the generated Markdown references and files in the extracted folder. Moving only the folder or only the Markdown can break those references.
DOCX margins, page layouts and complex tables do not map exactly to Markdown. Preserve the original DOCX and compare headings, body, tables and images before using a copy. Before reading it in Obsidian, also check the standard Markdown file and attachment paths.
Distinguish PDF engines and conversion direction
Producing PDF and reading PDF to create another format are different capabilities.
| Task | Conditions |
|---|---|
| Markdown → DOCX | No PDF engine required for basic conversion |
| Markdown → PDF | Default method requires a LaTeX engine; check --pdf-engine for alternatives |
| PDF → Word or Markdown | PDF is absent from the current official input-format list |
| OCR on scanned images or PDFs | Outside these document-conversion examples |
PDF output can require additional setup for the selected engine, fonts and content. You do not need to install a LaTeX environment just to convert to Word. For ordinary PDF export through a GUI, first check Typora’s native export conditions.
When a command or output fails
| Symptom | Check in order |
|---|---|
| pandoc command not found | Installation → new terminal → PATH and duplicate installations |
| Input file not found | Working directory → exact name and extension → quotes around paths with spaces |
| Images missing | Actual files → relative paths from the working directory → resource-path |
| PDF engine not found | DOCX versus PDF goal → installation and requirements of the selected PDF engine |
| Word layout differs from the source | Document structure and format differences → complex tables, margins and output pages |
Identify whether the error names an input file, output format or engine. Once the result is checked, keep the original and any required image files together.
Official sources
- Official project, supported formats and license ↗
- Official installation, PATH and PDF requirements ↗
- Official getting started — terminal, version and working directory ↗
- Official manual — input, output, media and PDF engines ↗
