[{"data":1,"prerenderedAt":630},["Reactive",2],{"/tools/markdown-to-pdf":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"seoTitle":10,"lead":11,"date":12,"dateModified":12,"author":13,"faq":14,"body":27,"_type":516,"_id":626,"_source":627,"_file":628,"_extension":629},"/tools/markdown-to-pdf","tools",false,"","Markdown to PDF converter","Paste Markdown or open a .md file and get a PDF back, with page numbers and your page size. See the HTML it becomes and the API call that makes the same PDF.","Markdown to PDF Converter: Free, with Page Numbers | PDFShift","Paste Markdown or open a .md file, and get it back as a PDF.","2026-12-05","Cyril Nicodème",[15,18,21,24],{"question":16,"answer":17},"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.",{"question":19,"answer":20},"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.",{"question":22,"answer":23},"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.",{"question":25,"answer":26},"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.",{"type":28,"children":29,"toc":613},"root",[30,38,45,47,206,211,240,261,440,446,462,475,481,486,498,535,548,570,576,582,586,591,595,600,604,609],{"type":31,"tag":32,"props":33,"children":34},"element","p",{},[35],{"type":36,"value":37},"text","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.",{"type":31,"tag":39,"props":40,"children":42},"h2",{"id":41},"what-markdown-cant-say-and-where-you-set-it",[43],{"type":36,"value":44},"What Markdown can't say, and where you set it",{"type":36,"value":46},"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",{"type":31,"tag":48,"props":49,"children":50},"table",{},[51,70],{"type":31,"tag":52,"props":53,"children":54},"thead",{},[55],{"type":31,"tag":56,"props":57,"children":58},"tr",{},[59,65],{"type":31,"tag":60,"props":61,"children":62},"th",{},[63],{"type":36,"value":64},"What the PDF needs",{"type":31,"tag":60,"props":66,"children":67},{},[68],{"type":36,"value":69},"Where it's decided",{"type":31,"tag":71,"props":72,"children":73},"tbody",{},[74,95,114,135,172,193],{"type":31,"tag":56,"props":75,"children":76},{},[77,83],{"type":31,"tag":78,"props":79,"children":80},"td",{},[81],{"type":36,"value":82},"Paper size",{"type":31,"tag":78,"props":84,"children":85},{},[86,93],{"type":31,"tag":87,"props":88,"children":90},"code",{"className":89},[],[91],{"type":36,"value":92},"format",{"type":36,"value":94}," in the API call, the Page size buttons here. A4 unless you pick another.",{"type":31,"tag":56,"props":96,"children":97},{},[98,103],{"type":31,"tag":78,"props":99,"children":100},{},[101],{"type":36,"value":102},"Orientation",{"type":31,"tag":78,"props":104,"children":105},{},[106,112],{"type":31,"tag":87,"props":107,"children":109},{"className":108},[],[110],{"type":36,"value":111},"landscape",{"type":36,"value":113},", the Landscape box.",{"type":31,"tag":56,"props":115,"children":116},{},[117,122],{"type":31,"tag":78,"props":118,"children":119},{},[120],{"type":36,"value":121},"A page break",{"type":31,"tag":78,"props":123,"children":124},{},[125,127,133],{"type":36,"value":126},"A ",{"type":31,"tag":87,"props":128,"children":130},{"className":129},[],[131],{"type":36,"value":132},"\u003Cdiv style=\"break-after: page\">\u003C/div>",{"type":36,"value":134}," line in your Markdown, with an empty line above and below it.",{"type":31,"tag":56,"props":136,"children":137},{},[138,143],{"type":31,"tag":78,"props":139,"children":140},{},[141],{"type":36,"value":142},"Page numbers",{"type":31,"tag":78,"props":144,"children":145},{},[146,148,154,156,162,164,170],{"type":36,"value":147},"The API's ",{"type":31,"tag":87,"props":149,"children":151},{"className":150},[],[152],{"type":36,"value":153},"footer",{"type":36,"value":155},", with ",{"type":31,"tag":87,"props":157,"children":159},{"className":158},[],[160],{"type":36,"value":161},"{{page}}",{"type":36,"value":163}," and ",{"type":31,"tag":87,"props":165,"children":167},{"className":166},[],[168],{"type":36,"value":169},"{{total}}",{"type":36,"value":171}," where the numbers go. The Page numbers box adds one.",{"type":31,"tag":56,"props":173,"children":174},{},[175,180],{"type":31,"tag":78,"props":176,"children":177},{},[178],{"type":36,"value":179},"Images",{"type":31,"tag":78,"props":181,"children":182},{},[183,185,191],{"type":36,"value":184},"A full ",{"type":31,"tag":87,"props":186,"children":188},{"className":187},[],[189],{"type":36,"value":190},"https://",{"type":36,"value":192}," address in the Markdown.",{"type":31,"tag":56,"props":194,"children":195},{},[196,201],{"type":31,"tag":78,"props":197,"children":198},{},[199],{"type":36,"value":200},"Fonts, colors and spacing",{"type":31,"tag":78,"props":202,"children":203},{},[204],{"type":36,"value":205},"The stylesheet in the HTML document.",{"type":31,"tag":32,"props":207,"children":208},{},[209],{"type":36,"value":210},"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.",{"type":31,"tag":212,"props":213,"children":215},"guide-figure",{"caption":214},"The sample report from the converter, made with an API key.",[216],{"type":31,"tag":217,"props":218,"children":220},"guide-page-pair",{":names":219},"[\"Page 1\", \"Page 2\"]",[221,232],{"type":31,"tag":32,"props":222,"children":223},{},[224],{"type":31,"tag":225,"props":226,"children":231},"img",{"alt":227,"height":228,"src":229,"width":230},"Page 1 of the sample weekly report as a PDF: the title, a summary line, a five-row table of PDFs per day, a list of changes, a task list with one item ticked and a quote, with Page 1 of 2 centered at the bottom.",843,"/images/tools/markdown-to-pdf/sample-report-page-1.webp",596,[],{"type":31,"tag":32,"props":233,"children":234},{},[235],{"type":31,"tag":225,"props":236,"children":239},{"alt":237,"height":228,"src":238,"width":230},"Page 2 of the same PDF: the heading The call we make and a JSON code block on a gray background, with Page 2 of 2 at the bottom.","/images/tools/markdown-to-pdf/sample-report-page-2.webp",[],{"type":31,"tag":32,"props":241,"children":242},{},[243,245,251,253,259],{"type":36,"value":244},"The PDF is printed on our server, which can't see your disk, so ",{"type":31,"tag":87,"props":246,"children":248},{"className":247},[],[249],{"type":36,"value":250},"![logo](./images/logo.png)",{"type":36,"value":252}," prints as a broken-image icon with its alt text. The same image at ",{"type":31,"tag":87,"props":254,"children":256},{"className":255},[],[257],{"type":36,"value":258},"https://pdfshift.io/images/logo.png",{"type":36,"value":260}," prints.",{"type":31,"tag":212,"props":262,"children":264},{"caption":263},"Two lines Markdown can't do on its own: the page break, and an image our server can fetch.",[265],{"type":31,"tag":266,"props":267,"children":275},"svg",{"viewBox":268,"xmlns":269,"role":225,"ariaLabelledBy":270,"style":273,"fontFamily":274},"0 0 560 236","http://www.w3.org/2000/svg",[271,272],"md2pdf-lines-title","md2pdf-lines-desc","max-width:560px;min-width:420px;display:block;margin:0 auto","DM Sans, sans-serif",[276,282,288,297,302,305,314,404],{"type":31,"tag":277,"props":278,"children":279},"title",{"id":271},[280],{"type":36,"value":281},"The page break line and a full image address in a Markdown file",{"type":31,"tag":283,"props":284,"children":285},"desc",{"id":272},[286],{"type":36,"value":287},"A Markdown editor with six numbered lines. Line 3 is a div with style break-after: page, marked \"Page 2 starts here\". Line 5 is an image with a relative path, ./images/logo.png, marked \"Broken icon in the PDF\". Line 6 is the same image at https://pdfshift.io/images/logo.png, marked \"Prints\".",{"type":31,"tag":289,"props":290,"children":296},"rect",{"x":291,"y":291,"width":292,"height":293,"rx":291,"fill":294,"stroke":295},"10","540","216","#FFFFFF","#DBE4F2",[],{"type":31,"tag":289,"props":298,"children":301},{"x":291,"y":291,"width":292,"height":299,"rx":291,"fill":300},"34","#F3EFFF",[],{"type":31,"tag":289,"props":303,"children":304},{"x":291,"y":299,"width":292,"height":291,"fill":300},[],{"type":31,"tag":36,"props":306,"children":311},{"x":307,"y":308,"fill":309,"style":310},"28","32","#0A0C3D","font-size:13px;font-weight:700",[312],{"type":36,"value":313},"report.md",{"type":31,"tag":315,"props":316,"children":318},"g",{"style":317},"font-size:12px;font-family:Source Code Pro, monospace",[319,359,373,381,385,391,395,399],{"type":31,"tag":315,"props":320,"children":322},{"fill":321},"#4C556D",[323,329,335,341,347,353],{"type":31,"tag":36,"props":324,"children":326},{"x":307,"y":325},"70",[327],{"type":36,"value":328},"1",{"type":31,"tag":36,"props":330,"children":332},{"x":307,"y":331},"96",[333],{"type":36,"value":334},"2",{"type":31,"tag":36,"props":336,"children":338},{"x":307,"y":337},"122",[339],{"type":36,"value":340},"3",{"type":31,"tag":36,"props":342,"children":344},{"x":307,"y":343},"148",[345],{"type":36,"value":346},"4",{"type":31,"tag":36,"props":348,"children":350},{"x":307,"y":349},"174",[351],{"type":36,"value":352},"5",{"type":31,"tag":36,"props":354,"children":356},{"x":307,"y":355},"200",[357],{"type":36,"value":358},"6",{"type":31,"tag":315,"props":360,"children":361},{"fill":309},[362,368],{"type":31,"tag":36,"props":363,"children":365},{"x":364,"y":325},"52",[366],{"type":36,"value":367},"> We'll watch it.",{"type":31,"tag":36,"props":369,"children":370},{"x":364,"y":343},[371],{"type":36,"value":372},"## The call we make",{"type":31,"tag":289,"props":374,"children":380},{"x":375,"y":376,"width":377,"height":378,"rx":346,"fill":300,"stroke":379},"46","107","300","22","#6C47FF",[],{"type":31,"tag":36,"props":382,"children":383},{"x":364,"y":337,"fill":309},[384],{"type":36,"value":132},{"type":31,"tag":289,"props":386,"children":390},{"x":375,"y":387,"width":377,"height":378,"rx":346,"fill":388,"stroke":389},"159","#FFF4E6","#FF9D28",[],{"type":31,"tag":36,"props":392,"children":393},{"x":364,"y":349,"fill":309},[394],{"type":36,"value":250},{"type":31,"tag":289,"props":396,"children":398},{"x":375,"y":397,"width":377,"height":378,"rx":346,"fill":300,"stroke":379},"185",[],{"type":31,"tag":36,"props":400,"children":401},{"x":364,"y":355,"fill":309},[402],{"type":36,"value":403},"![logo](https://pdfshift.io/images/…)",{"type":31,"tag":315,"props":405,"children":407},{"style":406,"fill":309},"font-size:12px",[408,416,422,426,431,435],{"type":31,"tag":409,"props":410,"children":415},"line",{"x1":411,"y1":412,"x2":413,"y2":412,"stroke":379,"style":414},"350","118","372","stroke-width:1.5",[],{"type":31,"tag":36,"props":417,"children":419},{"x":418,"y":337},"378",[420],{"type":36,"value":421},"Page 2 starts here",{"type":31,"tag":409,"props":423,"children":425},{"x1":411,"y1":424,"x2":413,"y2":424,"stroke":389,"style":414},"170",[],{"type":31,"tag":36,"props":427,"children":428},{"x":418,"y":349},[429],{"type":36,"value":430},"Broken icon in the PDF",{"type":31,"tag":409,"props":432,"children":434},{"x1":411,"y1":433,"x2":413,"y2":433,"stroke":379,"style":414},"196",[],{"type":31,"tag":36,"props":436,"children":437},{"x":418,"y":355},[438],{"type":36,"value":439},"Prints",{"type":31,"tag":39,"props":441,"children":443},{"id":442},"the-html-your-markdown-becomes",[444],{"type":36,"value":445},"The HTML your Markdown becomes",{"type":31,"tag":32,"props":447,"children":448},{},[449,451,460],{"type":36,"value":450},"The HTML tab above shows the exact document we send. Your browser turns the Markdown into HTML with ",{"type":31,"tag":452,"props":453,"children":457},"a",{"href":454,"rel":455},"https://marked.js.org/",[456],"nofollow",[458],{"type":36,"value":459},"marked",{"type":36,"value":461},", 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.",{"type":31,"tag":32,"props":463,"children":464},{},[465,467,473],{"type":36,"value":466},"To change how it looks, copy the HTML, edit the stylesheet at the top and send it from your code. The ",{"type":31,"tag":452,"props":468,"children":470},{"href":469},"/tools/html-viewer/",[471],{"type":36,"value":472},"HTML viewer",{"type":36,"value":474}," shows the result at A4 width before you spend a conversion.",{"type":31,"tag":39,"props":476,"children":478},{"id":477},"from-your-code-or-your-agent",[479],{"type":36,"value":480},"From your code or your agent",{"type":31,"tag":32,"props":482,"children":483},{},[484],{"type":36,"value":485},"It's the same two steps: Markdown to HTML with your language's library, then one call. In Node:",{"type":31,"tag":487,"props":488,"children":493},"pre",{"className":489,"code":491,"language":492,"meta":7},[490],"language-javascript","import { marked } from 'marked'\nimport { writeFile } from 'node:fs/promises'\n\nconst markdown = '# Weekly report\\n\\n| Day | PDFs |\\n|---|---:|\\n| Monday | 412 |'\nconst html = `\u003C!DOCTYPE html>\u003Chtml>\u003Chead>\u003Cmeta charset=\"utf-8\">\u003C/head>\u003Cbody>${marked.parse(markdown)}\u003C/body>\u003C/html>`\n\nconst response = await fetch('https://api.pdfshift.io/v3/convert/pdf', {\n  method: 'POST',\n  headers: { 'X-API-Key': process.env.PDFSHIFT_API_KEY, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n    source: html,\n    footer: { source: '\u003Cdiv style=\"font-size:9px;text-align:center;width:100%\">Page {{page}} of {{total}}\u003C/div>' }\n  })\n})\nawait writeFile('report.pdf', Buffer.from(await response.arrayBuffer()))\n","javascript",[494],{"type":31,"tag":87,"props":495,"children":496},{"__ignoreMap":7},[497],{"type":36,"value":491},{"type":31,"tag":32,"props":499,"children":500},{},[501,503,509,511,517,519,525,527,533],{"type":36,"value":502},"Send a full document that starts with ",{"type":31,"tag":87,"props":504,"children":506},{"className":505},[],[507],{"type":36,"value":508},"\u003C!DOCTYPE html>",{"type":36,"value":510},", not just the fragment marked returns. In Python, the ",{"type":31,"tag":87,"props":512,"children":514},{"className":513},[],[515],{"type":36,"value":516},"markdown",{"type":36,"value":518}," package does the first step, and the ",{"type":31,"tag":452,"props":520,"children":522},{"href":521},"/guides/html-to-pdf-python/",[523],{"type":36,"value":524},"Python HTML to PDF guide",{"type":36,"value":526}," covers the call. The ",{"type":31,"tag":452,"props":528,"children":530},{"href":529},"/guides/html-to-pdf-node/",[531],{"type":36,"value":532},"Node guide",{"type":36,"value":534}," has more on the request.",{"type":31,"tag":32,"props":536,"children":537},{},[538,540,546],{"type":36,"value":539},"AI agents write their answers and reports in Markdown already. Have the agent convert it to HTML and call PDFShift, directly or through our ",{"type":31,"tag":452,"props":541,"children":543},{"href":542},"/agents/mcp/",[544],{"type":36,"value":545},"MCP server",{"type":36,"value":547},", and the report lands as a PDF without a browser on your side.",{"type":31,"tag":32,"props":549,"children":550},{},[551,553,560,562,568],{"type":36,"value":552},"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 ",{"type":31,"tag":452,"props":554,"children":557},{"href":555,"rel":556},"https://www.capterra.com/p/184246/PDFShift/reviews/",[456],[558],{"type":36,"value":559},"4.8 stars from 65 reviews on Capterra",{"type":36,"value":561},". ",{"type":31,"tag":452,"props":563,"children":565},{"href":564},"/register/",[566],{"type":36,"value":567},"Create a free account",{"type":36,"value":569}," to get your key.",{"type":31,"tag":39,"props":571,"children":573},{"id":572},"frequently-asked-questions",[574],{"type":36,"value":575},"Frequently asked questions",{"type":31,"tag":577,"props":578,"children":580},"h3",{"id":579},"how-can-i-convert-a-markdown-file-to-a-pdf-for-free",[581],{"type":36,"value":16},{"type":31,"tag":32,"props":583,"children":584},{},[585],{"type":36,"value":17},{"type":31,"tag":577,"props":587,"children":589},{"id":588},"what-is-the-best-markdown-to-pdf-converter",[590],{"type":36,"value":19},{"type":31,"tag":32,"props":592,"children":593},{},[594],{"type":36,"value":20},{"type":31,"tag":577,"props":596,"children":598},{"id":597},"how-can-i-convert-a-markdown-file-to-pdf-on-windows",[599],{"type":36,"value":22},{"type":31,"tag":32,"props":601,"children":602},{},[603],{"type":36,"value":23},{"type":31,"tag":577,"props":605,"children":607},{"id":606},"does-it-render-math-or-mermaid-diagrams",[608],{"type":36,"value":25},{"type":31,"tag":32,"props":610,"children":611},{},[612],{"type":36,"value":26},{"title":7,"searchDepth":614,"depth":614,"links":615},2,[616,617,618,619],{"id":41,"depth":614,"text":44},{"id":442,"depth":614,"text":445},{"id":477,"depth":614,"text":480},{"id":572,"depth":614,"text":575,"children":620},[621,623,624,625],{"id":579,"depth":622,"text":16},3,{"id":588,"depth":622,"text":19},{"id":597,"depth":622,"text":22},{"id":606,"depth":622,"text":25},"content:tools:markdown-to-pdf.md","content","tools/markdown-to-pdf.md","md",1796486665189]