To convert Mermaid to PDF, paste the diagram code (or a Markdown file with ```mermaid blocks) into the editor above, check the preview, click Download PDF and choose "Save as PDF" in the print dialog. Every Mermaid block is drawn as a vector diagram and the source code is not printed. Headings, text, tables and code around the diagrams come through as well.
What does the output look like?
Raw Mermaid code, as in a .mmd file
graph TD
A[Request] --> B{Cached?}
B -- yes --> C[Return cache]
B -- no --> D[Query DB]One page with the flowchart drawn: a Request box,
a Cached? diamond and two labelled branches.
No code fence is needed; the tool adds it.A design doc with two diagrams
# Checkout
```mermaid
flowchart LR
Cart --> Pay --> Confirm
```
## Payment call
```mermaid
sequenceDiagram
API->>Stripe: Create intent
Stripe-->>API: client_secret
```The Checkout heading, then the flowchart, then the
Payment call heading and the sequence diagram with
its lifelines and arrows. Text stays selectable.How do I export a Mermaid diagram as a PDF without installing anything?
Use this page. The official command line route is mermaid-cli: install it with npm install -g @mermaid-js/mermaid-cli and run mmdc -i diagram.mmd -o diagram.pdf. That is the better choice for many files or a build script, and it sizes the PDF to the diagram rather than to a paper page. For one diagram or one document, pasting it here is faster.
Which diagram types work?
Anything the bundled Mermaid 11 can draw: flowchart and graph, sequence, class, state, ER, Gantt, pie, journey, mindmap, timeline, git graph, quadrant and the newer beta types. If a type renders in the Mermaid Editor, it renders here.
Should I use PNG, SVG or PDF?
PDF when the diagram goes into a document someone will read or print, or when you have text around it. SVG or PNG when you are embedding the diagram somewhere else, such as a slide or a wiki page: the Mermaid Editor downloads both. For a Word file with the diagram as a picture, use Markdown to Word.
How are tables, code, front matter and other edge cases handled?
| Input | What you get |
|---|---|
| Raw Mermaid, no fences | Wrapped in a mermaid block automatically |
| %% comments and %%{init}%% directives | Kept and passed to Mermaid |
| Several ```mermaid blocks | Each one drawn where it sits in the document |
| Invalid diagram | Shown as its code; the rest still renders |
| Very wide flowchart | Scaled to the page width. Use landscape or a TD direction for larger text |
| Math, tables, code | Rendered the same as on Markdown to PDF |
Maintained by Ankit Aglawe. Last updated .
Related Tools
Need a different format? See every tool on the Markdown converter page, or go back to the MDConvert home page.