Mermaid to PDF

Markdown
Preview — Modern
Upload a Markdown file or paste contentDrag & drop a .md file here, or use the buttons below

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

Mermaid in
graph TD
  A[Request] --> B{Cached?}
  B -- yes --> C[Return cache]
  B -- no --> D[Query DB]
In the PDF
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

Markdown in
# Checkout

```mermaid
flowchart LR
  Cart --> Pay --> Confirm
```

## Payment call

```mermaid
sequenceDiagram
  API->>Stripe: Create intent
  Stripe-->>API: client_secret
```
In the PDF
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?

InputWhat you get
Raw Mermaid, no fencesWrapped in a mermaid block automatically
%% comments and %%{init}%% directivesKept and passed to Mermaid
Several ```mermaid blocksEach one drawn where it sits in the document
Invalid diagramShown as its code; the rest still renders
Very wide flowchartScaled to the page width. Use landscape or a TD direction for larger text
Math, tables, codeRendered 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.

Mermaid to PDF questions

Can I paste just the Mermaid code, without Markdown?
Yes. If the input starts with a diagram keyword such as graph, flowchart, sequenceDiagram, gantt or erDiagram and has no code fences, it is treated as one diagram. Lines starting with %% and a --- front matter block before the keyword are allowed.
Can I open a .mmd file?
Yes. Upload .mmd, .md or .txt, or drop the file on the page. It is read in your browser.
Is the diagram in the PDF a picture or vector graphics?
Vector. The browser prints the SVG that Mermaid draws, so lines and labels stay sharp at any zoom.
My diagram is wide and comes out small. What can I do?
Diagrams are scaled to fit the page width. In the print dialog, switch Layout to Landscape, or change the diagram direction from LR to TD so it grows down the page instead of across.
What happens if my Mermaid code has a syntax error?
That block is shown as code instead of a diagram, and the rest of the document still renders. Fix it in the Mermaid Editor, which shows the error message, then paste it back.
Is my diagram uploaded?
No. Mermaid runs in your browser tab, and the PDF comes from your browser's own print dialog.