Markdown to PDF Converter

Write or paste Markdown, check the live preview, and save it as a PDF with headings, tables and code blocks intact.

Your Markdown and page settings

Preview

This opens your browser's print dialog. Choose Save as PDF as the destination and turn off Headers and footers.

Loading the Markdown engine...

How to convert Markdown to PDF

  1. Type or paste into Markdown source, or press Open Markdown file to load a .md file. Sample restores the example and Clear empties the box.
  2. Check the Preview, which updates as you type.
  3. Choose Page size, Orientation and Margins, and set a File name.
  4. Click Save as PDF. In the print dialog pick Save as PDF as the destination, turn off Headers and footers, and save.

How it works

Your text is converted to HTML by marked, which follows the GitHub Flavored Markdown specification. The HTML is then cleaned with DOMPurify, which strips scripts and event handlers, and shown in a sandboxed preview frame with a print style sheet and an @page rule for your page size and margins. Saving uses your browser's print engine, so the PDF keeps selectable text and working links, and long code lines wrap instead of being cut off.

Worked example

The box starts with a short sample: a title, a checklist with two checked and one open item, a block quote, a two-column table (Apples 3, Pears 12) and a code block. With the defaults (US Letter, Portrait, 0.75 in margins, file name document) the status line reads "Preview ready. Printing will use US Letter, portrait, 0.75 in margins. Nothing was removed." Click Save as PDF, choose Save as PDF, and the sample becomes a one-page document.pdf.

Limits and edge cases

Frequently asked questions

Which Markdown features are supported?

Everything in GitHub Flavored Markdown: headings, bold, italics, strikethrough, ordered and bulleted lists, task lists, tables, block quotes, fenced code blocks, links, images and horizontal rules. Raw HTML inside the Markdown also works after it is cleaned. Footnotes, math formulas, diagrams and emoji shortcodes such as :smile: are not converted.

Can I convert a README.md file?

Yes. Press Open Markdown file and choose the .md file, or paste its text. The file stays on your device. Relative image paths and badges that point to web addresses will not load, because only images embedded as data: addresses are allowed in the preview.

How do I start a new page in the PDF?

Add a line of raw HTML where the page should end: <div style="break-after: page"></div>. Everything after it starts on a new page. You can also add style="break-inside: avoid" to a block to keep it from splitting across two pages.

Why does the PDF show a date and web address in the margins?

Those lines come from the browser's print dialog, not from this tool. Open More settings in the dialog and turn off Headers and footers, then choose Save as PDF as the destination.

To edit and read Markdown without making a file, use Markdown Preview. To get the HTML itself, use Markdown to HTML. For styled pages you code by hand, try HTML to PDF.

Sources: GitHub Flavored Markdown Spec; marked documentation; MDN, CSS @page; MDN, break-inside.