How to Create PDF From Markdown

Markdown is the lingua franca of developer documentation, README files, and technical writing — but sharing .md files with non-technical stakeholders rarely works. Converting Markdown to PDF preserves your formatting, code blocks, and tables in a universally readable document. SublimePDF's API accepts raw Markdown or a Markdown file and returns a styled PDF with syntax-highlighted code, proper heading hierarchy, and automatic table of contents.

Follow the step-by-step instructions below, then use the free tool directly — no registration or download required.

Open Tool →

How to Create PDF From Markdown — Step by Step

1

Prepare your Markdown source

Write or export your Markdown content. SublimePDF supports CommonMark and GitHub Flavored Markdown (GFM) including tables, task lists, footnotes, and fenced code blocks with language identifiers.

2

Send a POST request to the conversion endpoint

POST your Markdown content to /api/v1/markdown-to-pdf. Pass the raw Markdown string in the request body as { "markdown": "# Your content..." } with Content-Type: application/json, or upload a .md file as multipart/form-data.

3

Configure styling options

Include optional parameters: 'theme' (github, academic, minimal), 'fontSize' (default 12pt), 'codeTheme' (monokai, github-light, dracula), and 'pageSize' (A4, Letter). These control the visual appearance of the rendered PDF.

4

Enable table of contents generation

Set "toc": true in your request body to auto-generate a clickable table of contents from your heading hierarchy. The TOC respects heading levels h1–h4 and includes page numbers.

5

Retrieve the generated PDF

The API responds with the PDF binary in the response body (Content-Type: application/pdf) or a download URL if you set "async": true. For large documents, async mode avoids request timeouts.

Pro Tips

  • 💡 Use fenced code blocks with language identifiers (```python, ```javascript) to get syntax highlighting in the PDF — unlabeled blocks render as plain monospace text.
  • 💡 Front matter (YAML between --- delimiters) is parsed for title, author, and date metadata that appears on the PDF cover page when 'coverPage': true is set.
  • 💡 If your Markdown includes relative image paths, switch to absolute URLs or base64-encoded inline images — the API cannot resolve local file paths.
  • 💡 For long technical docs, combine the TOC option with page headers showing the current section title using "headerTemplate": "{{section}}" in your request.

Privacy & Security

All processing happens directly in your browser. Your files are never uploaded to any server — they remain on your device throughout the entire process. SublimePDF uses WebAssembly technology for fast, secure, client-side processing.

Works Everywhere

This tool works on any modern browser — Chrome, Firefox, Safari, or Edge — on desktop, tablet, or mobile. No software to install. PDF is an open ISO standard supported by all major platforms.

How to Create PDF From Markdown — FAQ

Which Markdown flavor does SublimePDF support?
SublimePDF supports CommonMark with GitHub Flavored Markdown extensions — tables, task lists, strikethrough, autolinks, and fenced code blocks. Custom extensions like Obsidian callouts or MDX components are not supported.
Can I use custom CSS with Markdown-to-PDF conversion?
Yes. Pass a 'customCss' string in your request body to override or extend the default theme styles. This lets you match your brand's fonts, colors, and spacing.
How are images in Markdown handled?
Images referenced by URL are fetched and embedded in the PDF. Base64-encoded inline images are also supported. Local file paths (./images/photo.png) won't resolve — use hosted URLs instead.
Is there a size limit for Markdown input?
The request body limit is 10 MB, which accommodates extremely long documents. For Markdown files with many large embedded images, use URL references instead of base64 to stay under the limit.

Ready to get started?

Use SublimePDF's free tools right now.

Open Tool