Markdown has no pages. It knows headings, lists, tables and code, and nothing about paper size, page breaks, page numbers or where to find an image. A PDF gets those from the step after Markdown: the HTML your Markdown is turned into, and the print settings. This converter shows you that step.
What Markdown can't say, and where you set it
| What the PDF needs | Where it's decided |
|---|---|
| Paper size | format in the API call, the Page size buttons here. A4 unless you pick another. |
| Orientation | landscape, the Landscape box. |
| A page break | A <div style="break-after: page"></div> line in your Markdown, with an empty line above and below it. |
| Page numbers | The API's footer, with {{page}} and {{total}} where the numbers go. The Page numbers box adds one. |
| Images | A full https:// address in the Markdown. |
| Fonts, colors and spacing | The stylesheet in the HTML document. |
The sample in the box has one break line, so it comes out as two pages, with "Page 1 of 2" and "Page 2 of 2" at the bottom.


The PDF is printed on our server, which can't see your disk, so  prints as a broken-image icon with its alt text. The same image at https://pdfshift.io/images/logo.png prints.
The HTML your Markdown becomes
The HTML tab above shows the exact document we send. Your browser turns the Markdown into HTML with marked, using GitHub Flavored Markdown, so tables, task lists and fenced code blocks come through. It wraps that in a full HTML document with a print stylesheet, then sends it to the PDFShift API with no key. Our Chromium prints it and the PDF comes back in the response. We don't keep a copy.
To change how it looks, copy the HTML, edit the stylesheet at the top and send it from your code. The HTML viewer shows the result at A4 width before you spend a conversion.
From your code or your agent
It's the same two steps: Markdown to HTML with your language's library, then one call. In Node:
import { marked } from 'marked'
import { writeFile } from 'node:fs/promises'
const markdown = '# Weekly report\n\n| Day | PDFs |\n|---|---:|\n| Monday | 412 |'
const html = `<!DOCTYPE html><html><head><meta charset="utf-8"></head><body>${marked.parse(markdown)}</body></html>`
const response = await fetch('https://api.pdfshift.io/v3/convert/pdf', {
method: 'POST',
headers: { 'X-API-Key': process.env.PDFSHIFT_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
source: html,
footer: { source: '<div style="font-size:9px;text-align:center;width:100%">Page {{page}} of {{total}}</div>' }
})
})
await writeFile('report.pdf', Buffer.from(await response.arrayBuffer()))
Send a full document that starts with <!DOCTYPE html>, not just the fragment marked returns. In Python, the markdown package does the first step, and the Python HTML to PDF guide covers the call. The Node guide has more on the request.
AI agents write their answers and reports in Markdown already. Have the agent convert it to HTML and call PDFShift, directly or through our MCP server, and the report lands as a PDF without a browser on your side.
For PDFs your app or agent makes on demand, PDFShift is one HTTP call, and we run the Chromium behind it. We've run PDFShift since 2018, and we hold 4.8 stars from 65 reviews on Capterra. Create a free account to get your key.
Frequently asked questions
How can I convert a Markdown file to a PDF for free?
Open it in the converter on this page and press Convert to PDF. No account needed. You get 10 conversions a day, each up to 2 MB and 30 seconds, and every page carries a small Created via PDFShift badge. From your own code, the free plan gives you 50 credits a month with no credit card.
What is the best Markdown to PDF converter?
One that shows you what sits between your Markdown and the PDF, the HTML and the print settings, and lets you change both. This page does that for one file. The PDFShift API takes the same HTML and settings for every PDF your app or your agent makes, and prints them the same way every time.
How can I convert a Markdown file to PDF on Windows?
In your browser, on this page. Click Open a .md file, pick the file and convert. Nothing to install, and it works the same on Windows, Mac and Linux.
Does it render math or Mermaid diagrams?
No. The converter turns Markdown into plain HTML, so a math or mermaid block prints as code. Turn the diagram or formula into an SVG or PNG first and add it as an image with a full https:// address.