How to Convert Markdown to PDF (Free, Online)

Turn a .md file into a polished PDF in under a minute, right in your browser.

Last updated

Convert Markdown to PDF in 4 steps

  1. Open Markdown Viewer Online and open your .md file (or paste your Markdown into the editor).
  2. Check the preview looks right.
  3. Choose Export → Print / Save as PDF (or press Ctrl/⌘ + P).
  4. In the print dialog, set Destination (or Printer) to Save as PDF, then click Save.

Only the formatted document is printed — the editor, toolbars and menus are left out automatically — and the PDF is named after your document. The PDF always uses the light theme so it prints cleanly, even if you work in dark mode.

Note

Everything happens in your browser. Your document is never uploaded to a conversion server, which makes this safe for private or confidential files.

Tips for a better PDF

Keep code block and table backgrounds

Browsers often drop background colours to save ink. In the print dialog, open More settings and turn on Background graphics (Chrome, Edge), or Print backgrounds (Safari, Firefox).

Remove the date and URL from the page edges

Turn off Headers and footers in the print dialog’s settings for a clean page.

Add page breaks

Put this on its own line where you want a new page to start:

<div style="page-break-after: always"></div>

Adjust margins and paper size

Use the Margins and Paper size options in the print dialog (A4 and US Letter both work well). Headings are kept with the paragraph that follows them, and code blocks, tables, images and diagrams avoid being split across pages where possible.

Other export options

  • Download .html: a single self-contained web page with the same styling — good for sharing or hosting.
  • Copy formatted text: paste straight into Google Docs, Microsoft Word, Outlook or Gmail with headings, lists, links and tables intact.
  • Share link: send a link that opens a copy of your document in Markdown Viewer Online.

Converting from the command line

If you need to convert many files automatically, the free tool Pandoc converts Markdown to PDF (pandoc input.md -o output.pdf, which requires a LaTeX engine) as well as to Word (pandoc input.md -o output.docx). For one-off documents, the browser method above is quicker and needs no setup.

Frequently asked questions

How do I convert Markdown to PDF for free?

Open your .md file in Markdown Viewer Online, choose Export → Print / Save as PDF, set the destination to “Save as PDF” and click Save. It’s free and the file is not uploaded.

Why are code block backgrounds missing in my PDF?

Most browsers skip background colours when printing. In the print dialog, open More settings and tick “Background graphics” (Chrome and Edge), or “Print backgrounds” (Safari and Firefox).

How do I add a page break in Markdown?

Markdown has no page-break syntax, but you can add HTML on its own line — <div style="page-break-after: always"></div> — and the PDF will start a new page there.

Can I convert Markdown to HTML instead?

Yes. Choose Export → Download .html to get a single, self-contained HTML file with the same styling.