pandoc
CLIUniversal document converter between dozens of formats.
Convert documents between Markdown, HTML, PDF, DOCX, and 40+ formats (PDF output needs LaTeX or a headless browser)
Verified commands
Executed by our harness on the platforms shown; the assertion checked the actual result, not just the exit code.
Convert Markdown to DOCX
pandoc input.md -o output.docxConvert Markdown to standalone HTML
pandoc input.md -s -o output.htmlConvert DOCX to Markdown
pandoc input.docx -t markdown -o output.mdCommon failures (1)
- Images not extractedAdd --extract-media=./media to save embedded images
Convert HTML to Markdown
pandoc -f html -t markdown input.html -o output.mdConvert Markdown to PDF without LaTeX (macOS, via Chrome)
macOS only
pandoc input.md -s -o tmp.html && "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --headless=new --disable-gpu --no-pdf-header-footer --print-to-pdf=output.pdf "file://$PWD/tmp.html"Common failures (1)
- pandoc input.md -o output.pdf fails with 'pdflatex not found'pandoc needs a LaTeX engine for PDF; rendering HTML with headless Chrome avoids installing TeX
Convert Markdown to PDF without LaTeX (Linux, via Chromium)
Linux only
pandoc input.md -s -o tmp.html && chromium --headless=new --no-sandbox --disable-gpu --no-pdf-header-footer --print-to-pdf=output.pdf "file://$PWD/tmp.html"More recipes
Curated from documentation and usage. Percentages are estimates, not measurements.
Convert Markdown to PDF with LaTeX
pandoc input.md -o output.pdf --pdf-engine=xelatexCommon failures (2)
- Error: pdflatex/xelatex not foundInstall a LaTeX engine (brew install basictex / apt install texlive-xetex), or use the Chrome route above
- Korean/CJK characters missingUse --pdf-engine=xelatex with -V mainfont='Noto Sans CJK KR'
Install
Homebrew
brew install pandocapt
sudo apt install pandocAgent notes
- When to use
- Document format conversion, generating PDFs or Word docs from Markdown
- Quick examples
pandoc README.md -o output.pdfpandoc doc.docx -t markdown
Use from an agent
curl -s https://clihub.com/api/tools/pandoc | jq '.agentHints.provenRecipes[] | {task, command, verified}'Or call get_tool with slug pandoc on the MCP server at https://clihub.com/mcp.