Diagram workflow

How to Publish Mermaid Diagrams in Substack Emails

Mermaid is ideal for keeping diagrams next to technical prose in a Markdown file. A Mermaid block is source code, however, and it needs JavaScript to become a visual diagram. Substack emails cannot execute that rendering pipeline inside a subscriber’s inbox.

By StackDraft Editorial8 min read
Short answer

Render the Mermaid block before publication, use a static PNG in the Substack draft, and keep a text explanation near the image. StackDraft detects fenced Mermaid code, renders it locally, and prepares the generated diagram as a publishing asset.

Prepare the draft while you follow the guide

StackDraft runs locally in your browser. No account or upload required.

Open StackDraft

Why a static image is the dependable format

On a documentation site, a Mermaid library reads the diagram source and creates SVG in the browser. An email client generally does not run arbitrary JavaScript, and Substack’s post editor is not a Mermaid renderer. Pasting the source therefore produces code or plain text, not a flowchart.

SVG is excellent on the web but has uneven support and security treatment across publishing and email systems. A sufficiently large PNG sacrifices infinite scaling, yet it is broadly predictable. Keep the original Mermaid source in your repository or vault so the diagram remains editable.

Start with a focused Mermaid block

The diagram has one reading direction, four nodes, short labels, and no decorative subgraph. That simplicity is a feature in an email column. If the explanation needs many branches, publish two diagrams that answer separate questions.

Markdown source
```mermaid
flowchart LR
  Draft[Markdown draft] --> Check[Publishing checks]
  Check --> Copy[Rich-text copy]
  Copy --> Post[Substack post]
  Post --> Email[Test email]
```

Convert Mermaid to a Substack-ready asset

  1. 01

    Keep the language marker

    Use mermaid immediately after the opening code fence so the converter can distinguish diagram source from ordinary code.

  2. 02

    Load the full post into StackDraft

    The preview detects each Mermaid block and renders it locally. No unpublished diagram source needs to be sent to a conversion service.

  3. 03

    Inspect the generated diagram

    Check labels, edge direction, contrast, and the smallest text. Fix the Mermaid source rather than trying to repair a raster image.

  4. 04

    Copy or export the prepared asset

    Use the prepared body for the publishing handoff. StackDraft also lists generated assets so you can export them when a manual upload is more reliable.

  5. 05

    Add context and alt text in Substack

    Introduce the question the diagram answers, add a concise image description, and explain the important path or conclusion in normal text.

  6. 06

    Check the test email

    Open the message on a phone and confirm every label is legible at the displayed width without zooming.

Design diagrams for a narrow newsletter

  • Use left-to-right flow for short pipelines and top-to-bottom flow for branching systems.
  • Keep labels to a few words; put explanations in the article body.
  • Prefer a small number of meaningful nodes over a complete architecture inventory.
  • Avoid pale text, hairline edges, and color combinations that disappear in dark mode.
  • Do not encode categories with color alone; use labels, shapes, or line styles too.
  • Split sequence diagrams with many participants into separate interactions.
  • Keep one diagram focused on one claim or process.

Provide a useful text alternative

A diagram description should communicate its purpose and important relationships. For the example above, useful alt text would be: ‘Publishing flow from a Markdown draft through compatibility checks and rich-text copy to a Substack post and test email.’ That is more informative than ‘flowchart’ and more concise than listing every visual property.

Complex diagrams need an adjacent prose explanation, not an enormous alt-text transcript. Describe the main path, decision, or conclusion in the article so readers who cannot inspect the image receive the same core insight.

Troubleshoot Mermaid publishing failures

  1. 01

    The block appears as code

    Confirm the opening fence is labeled mermaid and preview it in StackDraft before copying to Substack.

  2. 02

    Rendering reports a syntax error

    Reduce the diagram to the smallest valid version, then add nodes and edges back until the failing line is clear.

  3. 03

    The PNG is too dense

    Remove secondary detail, shorten labels, change direction, or split the diagram. Raising resolution cannot rescue an overloaded information design.

  4. 04

    PNG export falls back to SVG

    Reload and retry in a current desktop browser. If the browser blocks rasterization, export the listed SVG asset and convert it to PNG before uploading.

  5. 05

    The image is present but unclear in email

    Increase label contrast and simplify the source for the actual displayed width, then replace the asset and send another test.

Frequently asked questions

Can Substack render Mermaid code directly?

No. Mermaid source needs a rendering library, while Substack posts and emails should receive a static output such as PNG.

Should I use SVG or PNG for a Substack diagram?

PNG is generally the safer email asset. Keep the SVG or Mermaid source as the editable original, and use a high-resolution PNG for the publishing copy.

How large should a Mermaid diagram be?

There is no fixed node count, but every label should be readable at a phone-width display. If readers need to zoom or trace many crossing edges, split the diagram.

Does StackDraft send Mermaid source to a server?

No. StackDraft renders Mermaid in the browser and keeps the working draft local. You choose when to copy or export the generated asset.

Sources and further reading

S
StackDraft Editorial

These guides are maintained alongside StackDraft’s Markdown renderer, clipboard workflow, and publishing checks. Product behavior is verified against the current code; destination-platform behavior is reviewed against official support documentation.

Review the compatibility report
Ready to publish?

Turn the Markdown draft into clean Substack copy.

Preview the post, catch fragile blocks, and copy the title and body separately.

Open StackDraft free