# MD2PDF — Complete Documentation for AI Agents > MD2PDF is a free, open-source online tool that converts Markdown (.md) files into beautifully styled PDFs, HTML files, and PNG images. Features include Mermaid diagram rendering, auto table of contents, syntax highlighting for 180+ languages, and end-to-end encryption (AES-256-GCM). Runs entirely in the browser with no signup, no server processing, and no tracking. Includes a public REST API and an installable AI Skill. Website: https://md2pdf.studio GitHub: https://github.com/JSiapoDEV/md2pdf --- ## Features - Live split-pane editor with real-time Markdown preview - GitHub-Flavored Markdown (GFM) support - Syntax highlighting for 180+ programming languages (via highlight.js) - **Mermaid diagram rendering** (flowcharts, sequence diagrams, Gantt charts, pie charts, etc.) - **Auto table of contents** — write `[TOC]` anywhere to generate a linked TOC from headings - 11 visual styles for document rendering - Custom CSS injection for full styling control - Export to PDF (continuous single page), HTML (standalone with inlined styles), and PNG image - **End-to-end encryption** — all shared documents encrypted with AES-256-GCM - Share documents via URL with rich OG previews for WhatsApp, Teams, and Slack - Dark and light theme toggle - Drag-and-drop .md file upload - 5 built-in document templates - Word count and reading time indicator - Auto-save drafts to browser localStorage - Find and replace (Ctrl+F / Ctrl+H) - Copy button on every code block - Installable AI Skill in Claude Skills format - Public REST API for programmatic access - WebMCP declarative forms for browser-based AI agent integration - No cookies, no analytics, no server uploads — fully private --- ## Available Visual Styles | Style | Description | |-------|-------------| | notion | Clean, modern sans-serif (default) | | github | Classic GitHub markdown rendering | | minimal | Elegant serif typography, no decorations | | academic | Formal justified text with a scholarly feel | | corporate | Professional design with blue accents and styled table headers | | latex | Simulates academic papers with Libre Baskerville typography | | dracula | Vibrant purple, pink, and green on dark background | | newspaper | Editorial typography with Playfair Display headings | | handwritten | Cursive font with notebook-lined background | | terminal | Green-on-black monospace, hacker aesthetic | | pastel | Soft pink, purple, and teal with rounded elements | --- ## REST API Reference No authentication required. All endpoints accept and serve standard HTTP. All documents are encrypted at rest using AES-256-GCM. ### Create a Document ``` POST https://md2pdf.studio/api/save Content-Type: text/plain # Your Markdown content here Tables, code blocks, images, and all GFM syntax are supported. ``` **Response (JSON):** ```json { "id": "BrOrr0N3", "editKey": "a1b2c3d4e5f6...", "url": "https://md2pdf.studio/s/BrOrr0N3", "key": "xY9kL2mN..." } ``` - `url` — Base URL for the document - `editKey` — Secret key required to update the document later (save it!) - `key` — AES-256-GCM decryption key (save it!) **IMPORTANT:** Build the shareable link by appending the key to the URL hash: ``` {url}#k={key} ``` Example: `https://md2pdf.studio/s/BrOrr0N3#k=xY9kL2mN...` The `#k=` hash fragment is never sent to the server. Without it, the document cannot be decrypted. Only people with the full link can read the content. ### Update a Document ``` PUT https://md2pdf.studio/api/update/{id} Content-Type: text/plain X-Edit-Key: {editKey} X-Enc-Key: {key} # Updated Markdown content ``` The URL and encryption key stay the same — only the content is re-encrypted and updated. The 90-day expiration timer resets on update. ### cURL Examples **Create:** ```bash curl -X POST https://md2pdf.studio/api/save \ -H "Content-Type: text/plain" \ -d "# Hello World This is a styled document created via the API." # Response includes: id, editKey, url, key # Share: {url}#k={key} ``` **Update:** ```bash curl -X PUT https://md2pdf.studio/api/update/BrOrr0N3 \ -H "Content-Type: text/plain" \ -H "X-Edit-Key: a1b2c3d4e5f6" \ -H "X-Enc-Key: xY9kL2mN..." \ -d "# Updated Document New content goes here." ``` ### Security - All documents are encrypted at rest using **AES-256-GCM** - The decryption key (`key`) is returned in the API response and placed in the URL hash fragment (`#k=`) - The hash fragment is never sent to the server — only the person with the full link can decrypt - Cloudflare KV stores only ciphertext — the server cannot read document content ### Limits - **Max document size:** 500 KB - **Rate limit:** 10 requests per minute per IP - **Link expiration:** 90 days after last update --- ## AI Skill (Claude Skills Format) The following skill can be installed in Claude, Custom GPTs, Gemini, or any compatible AI agent. It allows the agent to create and share styled Markdown documents on behalf of the user. ```markdown --- name: md2pdf description: Create and share styled PDF, HTML, and image documents from Markdown via md2pdf.studio. Use when the user wants to export, share, or create a visually styled document from markdown content. --- # MD2PDF Skill Use this skill when the user asks you to: - Create a document or report from their request - Save or export markdown as a PDF, HTML, or image - Share a styled version of written content - Generate a shareable link for a document ## How to create a document 1. Write the content in Markdown format (GitHub-Flavored Markdown supported). 2. POST the markdown to the API: POST https://md2pdf.studio/api/save Content-Type: text/plain 3. You will receive: { "id": "...", "editKey": "...", "url": "...", "key": "..." } 4. Build the shareable link: {url}#k={key} 5. Share the full link (with #k=) with the user. Save id, editKey, and key for future updates. IMPORTANT: The document is encrypted at rest. The #k= hash contains the decryption key and is never sent to the server. Without it, the document is unreadable. ## How to update a document PUT https://md2pdf.studio/api/update/{id} Content-Type: text/plain X-Edit-Key: {editKey} X-Enc-Key: {key} The URL and encryption key stay the same — content is re-encrypted. ## Available styles notion (default), github, minimal, academic, corporate, latex, dracula, newspaper, handwritten, terminal, pastel ## Limits - Max document size: 500 KB - Rate limit: 10 req/min per IP - Expiration: 90 days (resets on update) - No authentication required ``` --- ## Document Templates Pre-built templates available in the editor: 1. **CV / Resume** — Professional resume layout 2. **Report** — Monthly or project report 3. **Documentation** — Technical project documentation 4. **Changelog** — Software release changelog 5. **Meeting Notes** — Structured meeting notes --- ## Supported Markdown Syntax MD2PDF supports full GitHub-Flavored Markdown (GFM) plus extensions: - Headings (H1–H6) with auto-generated anchor IDs - Paragraphs with line breaks - **Bold**, *italic*, ~~strikethrough~~ - Ordered and unordered lists - Task lists (checkboxes) - Code blocks with language-specific syntax highlighting (180+ languages) - Inline code - Tables with alignment - Blockquotes - Images (inline and reference) - Horizontal rules - Links (inline and reference) - **Mermaid diagrams** — use ` ```mermaid ` code blocks for flowcharts, sequence diagrams, Gantt charts, pie charts, class diagrams, state diagrams, ER diagrams, and more - **Auto table of contents** — write `[TOC]` on its own line to generate a linked table of contents from all headings --- ## Keyboard Shortcuts | Shortcut | Action | |----------|--------| | Ctrl+S / Cmd+S | Export to PDF | | Ctrl+F / Cmd+F | Find in editor | | Ctrl+H / Cmd+H | Find and replace | | Ctrl+Shift+L / Cmd+Shift+L | Toggle dark/light theme | | Tab | Insert tab in editor | --- ## Technical Details - Pure HTML, CSS, and JavaScript — no framework, no build step - marked.js (v12.0.1) for Markdown parsing - highlight.js (v11.9.0) for syntax highlighting (180+ languages) - html2canvas (v1.4.1) for image export - lz-string (v1.5.0) for URL compression - GitHub Markdown CSS (v5.5.1) as base styling - Hosted on Cloudflare Workers + KV for shared documents - Browser native print dialog for PDF export --- ## Author Built by JSiapoDev - Website: https://jsiapo.dev - GitHub: https://github.com/JSiapoDEV - LinkedIn: https://www.linkedin.com/in/jsiapo/