Markdown to PDF API

Markdown to PDF API: styled PDFs from plain Markdown

Send Markdown and get a clean, branded PDF back, with tables, footnotes and your own theme. Built for docs, reports and the Markdown your AI features already produce.

  • 50 free renders/month
  • No credit card
  • 4 print themes

What is a Markdown to PDF API?

A Markdown to PDF API converts Markdown text into a formatted PDF. You send the Markdown in an HTTP request; the service turns it into HTML, applies a print stylesheet with fonts, margins and page numbers, renders it in a browser engine and returns the PDF. You get a styled document without writing HTML or running a converter yourself.

Markdown to PDF API key facts
EndpointPOST https://api.dynamicdocumentapi.com/v1/pdf/from-markdown
MarkdownCommonMark plus tables, strikethrough, task lists, autolinks and footnotes
Themesdefault, github, academic, minimal, or none with your own CSS
VariablesJinja templating on the Markdown when you send data
Raw HTMLSanitized by default: harmless tags stay, scripts and other active content are removed. allow_raw_html switches the sanitizing off
Rendering engineEngine 2026.4 on Chromium (Chrome 153), same print options as HTML to PDF
PriceFree: 50 renders/month. Paid from €15/month (billed annually) for 3,000 renders, auto top-ups from €6 per 1,000

Convert Markdown to PDF in one request

Send the Markdown as a string, pick a theme, and optionally add CSS. Print settings such as paper size, margins and a page-number footer go into pdf, exactly as on the HTML to PDF API.

curl https://api.dynamicdocumentapi.com/v1/pdf/from-markdown \
  -H "Authorization: Bearer $DYNAMIC_DOCUMENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "markdown": "# Q3 report\n\nRevenue grew **18%**.\n\n| Region | Q3 |\n|---|---|\n| US | 492 |",
    "theme": "github",
    "css": "h1 { color: #4751e9; }",
    "pdf": {
      "paper":  { "size": "Letter" },
      "footer": { "enabled": true, "right": "Page {{page}} of {{pages}}" }
    },
    "delivery": "binary"
  }' \
  --output report.pdf
// Node.js 18+: turn a Markdown file into a PDF
import { readFile, writeFile } from "node:fs/promises";

const markdown = await readFile("README.md", "utf8");

const res = await fetch("https://api.dynamicdocumentapi.com/v1/pdf/from-markdown", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.DYNAMIC_DOCUMENT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ markdown, theme: "github", delivery: "binary" }),
});

await writeFile("README.pdf", Buffer.from(await res.arrayBuffer()));
import os
import pathlib
import requests

markdown = pathlib.Path("README.md").read_text()

res = requests.post(
    "https://api.dynamicdocumentapi.com/v1/pdf/from-markdown",
    headers={"Authorization": f"Bearer {os.environ['DYNAMIC_DOCUMENT_API_KEY']}"},
    json={"markdown": markdown, "theme": "github", "delivery": "binary"},
    timeout=60,
)
res.raise_for_status()
pathlib.Path("README.pdf").write_bytes(res.content)
<?php
$markdown = file_get_contents('README.md');

$ch = curl_init('https://api.dynamicdocumentapi.com/v1/pdf/from-markdown');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer ' . getenv('DYNAMIC_DOCUMENT_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS     => json_encode([
        'markdown' => $markdown,
        'theme'    => 'github',
        'delivery' => 'binary',
    ]),
]);
file_put_contents('README.pdf', curl_exec($ch));

Request fields

Fields of POST /v1/pdf/from-markdown
FieldWhat it does
markdownRequired. The Markdown text.
themedefault, github, academic, minimal or none.
cssExtra CSS on top of the theme, or the whole stylesheet with none.
dataJSON values for {{ variables }} in the Markdown.
templatingRun Jinja on the Markdown. On automatically when data is sent.
allow_raw_htmlKeep HTML written inside the Markdown exactly as it is, without sanitizing: scripts in it run. Default false, which sanitizes the output and keeps only harmless tags such as <br>. Turn it on only for Markdown you wrote yourself.
pdfPaper, margins, header and footer, page numbers, bookmarks, metadata.
deliveryurl (default, signed link), binary or base64.

Supported Markdown syntax

The parser follows CommonMark, the specification behind GitHub, GitLab and most editors, and adds the GitHub-style extensions people use in real documents. We list what is not built in as well, so you know before you start.

Markdown syntax support
SyntaxSupported
Headings, paragraphs, emphasis, lists, block quotes, links, imagesYes (CommonMark)
Tables with column alignmentYes
Task lists - [x]Yes
Strikethrough ~~text~~Yes
Footnotes [^1]Yes
Automatic links for bare URLsYes
Heading anchors for links and PDF bookmarksYes, plus bookmarks with pdf.outline
Fenced code blocksYes, monospaced, without color highlighting
Math (LaTeX), Mermaid diagramsNot built in; render them as images first
Raw HTMLHarmless tags by default; everything, unsanitized, with allow_raw_html

Four print themes, or your own CSS

Themes are print stylesheets tuned for paper: readable line lengths, sensible heading sizes, tables that do not overflow the page, and margins that work on A4 and Letter.

default

A neutral sans-serif document style at 11 pt, with ruled second-level headings. Good for reports, exports and anything that should simply look tidy.

github

Looks like a rendered README on a code-hosting site. Suits developer docs, changelogs and technical notes.

academic

Serif type, justified text with hyphenation, wider margins, and automatically numbered sections (1., 1.1, 1.2). Made for papers, research summaries and long reports.

minimal

Compact and monochrome at 10 pt, with plenty of white space and uppercase section headings. For letters, memos and internal documents.

Add brand colors and fonts with css, or set theme to none and write the full stylesheet. For a layout with a cover page, logo and legal footer around the Markdown, wrap it in a branded template: Markdown templates are stored and versioned like HTML templates, and the markdown filter drops Markdown into any HTML template.

Turn AI output into PDFs

Language models answer in Markdown: headings, bullet lists, tables and bold text. That makes Markdown to PDF the shortest path from an AI feature to a document a customer can download, print or file: a generated report, a meeting summary, a proposal draft, a research brief.

  • Send the answer as it is. No conversion step: the model's Markdown goes straight into markdown.
  • Safe by default. Model output is untrusted input. A prompt injection can make a model write HTML or scripts. By default the output is sanitized: scripts and other active content are removed, so nothing active ends up in the PDF. Leave allow_raw_html off for model output.
  • Branded, not generic. A theme plus your CSS, or a Markdown template with your header and footer, turns a chat answer into a document with your name on it.
  • Numbers the model should not touch. Put figures from your database into data and reference them as {{ variables }}, so the model writes the prose and your system supplies the facts.

Docs, READMEs and knowledge-base exports

Documentation already lives in Markdown. Generate a PDF handbook from the same files on every release, attach a PDF version of a README to a download, or let users export a knowledge-base article. Use pdf.outline to turn headings into PDF bookmarks, and a CSS rule such as h1 { break-before: page; } to start each chapter on a new page.

Markdown is one of four inputs of our PDF generation API. Need a layout Markdown cannot express, such as multi-column pages or a pixel-exact form? Write HTML instead, with the same engine and options.

Markdown to PDF API pricing

Free

€0

50 renders per month, same rendering engine.

Starter

€15 / month

3,000 renders per month, billed annually (€19 billed monthly). About €0.005 per render.

See all plans for larger volumes.

FAQ

Markdown to PDF API: frequently asked questions

Which Markdown flavor is supported?

CommonMark with the GitHub-style extensions tables, strikethrough, task lists, autolinks and footnotes. Headings get anchor IDs automatically. Syntax highlighting, math and Mermaid diagrams are not built in.

Can I apply my own CSS?

Yes. Pick one of the themes and add rules in css, or set theme to none and bring the complete stylesheet. Print features such as @page margins, page breaks and web fonts work as in any HTML document.

Does it highlight code blocks?

Code blocks render in a monospaced font with the theme's styling, but without colored syntax highlighting. If you need colors, highlight the code on your side, for example with highlight.js or Pygments, and send the resulting HTML to the HTML to PDF endpoint.

Can I convert ChatGPT or Claude output to PDF?

Yes. Language models write Markdown by default, so their answers can be sent as they are. HTML inside the Markdown is sanitized by default: scripts and other active content are removed, which protects the PDF from markup the model was tricked into writing. Leave allow_raw_html off for model output.

Is raw HTML inside Markdown allowed?

Harmless tags such as br or span work without a setting; scripts, event handlers and other active content are removed. If you set allow_raw_html to true, the HTML is kept exactly as written and nothing is sanitized, so scripts in it run. Use it only for Markdown you wrote yourself. Markdown templates stored in your account are always sanitized.

Can I use variables in Markdown?

Yes. Send data with the request and the Markdown is processed as a Jinja template first, so {{ customer }} or a {% for %} loop work just like in HTML templates.

Convert Markdown to PDF free

50 renders a month on the free plan, no credit card, auto top-ups on paid plans.

Start free