惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fox-IT International blog
Recent Announcements
Recent Announcements
D
Docker
IT之家
IT之家
B
Blog
Jina AI
Jina AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
量子位
C
Check Point Blog
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
博客园 - 司徒正美
李成银的技术随笔
美团技术团队
Blog — PlanetScale
Blog — PlanetScale
雷峰网
雷峰网
The GitHub Blog
The GitHub Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
T
The Blog of Author Tim Ferriss
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
L
LangChain Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
有赞技术团队
有赞技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
T
Tailwind CSS Blog
H
Help Net Security
Engineering at Meta
Engineering at Meta
小众软件
小众软件
B
Blog RSS Feed
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
M
Microsoft Research Blog - Microsoft Research
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog

DEV Community

From Vibe Coding to Agentic Engineering: The New Role of Software Engineers CDN Caching and Invalidation Build a video upload + HLS playback flow in Next.js 15 (with direct uploads) Automating NotebookLM with Hermes Agent: From Research to Multi-Platform Content A Startup founded in 2024 just signed a contract for thousands of robots at $25,000 each. Here Is the Moment Physical AI Made That Real. We Built an MCP Server. Here's Why the CLI Matters More. Apple Silicon's AI Ceiling Is Higher Than You Think MySQL Views: Your Database's Secret Weapon for Clean, Smart Queries 🎯 What is RAG? A Beginner's Guide to Retrieval-Augmented Generation (For Engineers Who Actually Build It) GUI Agents vs RPA: Different Architectures for Different Problems FinOps 2026: Step-by-Step Guide to Reducing Cloud Waste Without Stifling Innovation How to Cut 30% of Cloud Costs Without a FinOps Team Building Authentication Systems in Nest.js: A Complete Guide AI Isn't on Either Side of the Equation Google Wants Developers to “Vibe Code” — And Antigravity 2.0 Proves It I Tracked HN for 168 Days. AI Skepticism Just Crossed a Threshold Nobody's Talking About. Private AI Inference in 2026: HIPAA + GDPR Without the Hyperscaler Tax Great read! Matches my lean approach 😃 Can a Marketer Vibe-Code a Working App? 6 Lessons From My First Build Experienced devs are 19% slower with AI tools. Nobody wants to hear it. Breaking the Insurance Black Box: Engineering Production Ready, Compliant AI Systems The Safety Net Is Always Open Source The Pattern Paradox: When Hypervigilance Helps — and Hurts — Cybersecurity Analysts Why your AI workflow needs automated time tracking Your LLM Forgets Everything. Give It a Wiki! Compass v1.1.0 · we shipped a memory plugin that catches its own consumption drift Broken Links Are Costing You More Than You Think "My AI Assistant Could Code, But It Couldn't Operate My Desktop" Securing auth in a large-scale production system: three industry-standard architectures — and why none survived a closer look Two Models Just Hit 90% on Agent Coding. One Cost Less Than a Penny. Voicebox: The Open-Source AI Voice Studio That Just Hit 28K Stars How to Build a Remote Patient Monitoring App: Features, Architecture and Cost in 2026 Day 1 Python Learning 🐍 Supercharge your AI coding workflow with Chrome DevTools for agents. My AI corrections used to be tribal knowledge. I shipped the fix into my own OSS. Google Opened UCP for Lodging. We Already Tested What It Needs to Handle. I A/B tested compressed agent instructions and found the breaking point k6: The Tool, The Philosophy, and Your First Test AWS vs Azure vs GCP: A Real Cloud Pricing Comparison The floor problem: why every admin product wastes 3 months on the same foundation Turn Your Ideas into Great Products Taming DOM Events in React: useEventListener, useEventEmitter, useKeyModifier, useTextSelection, useDebounceFn, useThrottleFn Subnautica Interactive Map Using Cloudflare Turnstile Invisible Challenges for Mobile APIs Without Breaking the User Experience Log Aggregation in .NET 8: Seq vs ELK vs Loki Commanding the Command Line Using the Terminal in VS Code "My AI Assistant Could Code, But It Couldn't Operate My Desktop" Google Just Killed the Blue Link: 5 Ways to Survive the AI Search Apocalypse Open Source Is How Small Teams Build Big Things Terraform Drift Detection and Recovery on Google Cloud: Plan, Import, State, and GitHub Actions Using VS Code with WSL Your AI Agent Just Got Compromised. Now What? Reinstalling your Claude Code environment on a new machine GitHub Is Dying and Microsoft Is Holding the Knife: The 2026 Developer Betrayal No One Saw Coming (But We All Should Have) git bisect: Find the Commit That Broke Everything CKP LLM: The Missing Layer Between Your AI Agent and Its Knowledge Base My AI Agent Was Escalating Every Contract. One Decision Layer Fixed It 📑🤖📑🤖 Writing High-Performance Kernels in TileLang, from GEMM to MLA Building a Printable Library with Next.js and Cloudflare: Practical Notes CQRS: Where It Helps and Where It Hurts in Backend Systems Fast-Track CBT: A Clean, Zero-Stress Online Testing Platform Cleaning Background Noise and Scaling AI Scraping Quiet Exits, Quiet Collapse (Part 2): How Organizations Remove People without Signal I Built a Free Giveaway Discord Bot (Open Source Project) How I Finally Shipped PharmVerify NG — an AI Drug Checker for Nigerian Patients published: true tags: devchallenge, githubchallenge Why Your Requests + BeautifulSoup Stack Will Fail in Production Why Java + Spring Boot is Still the King of Enterprise Backend (2026) Spring Native + Cloud Run : cold-start 18, RAM 3, facture à 0 FCFA DS - while loop Comment structurer une API simple avec Go pour plus de clarté Complete llms.txt guide for 2026 Cinema Seat Reservation System — From Baseline Local Development To Live Cloud-Native Production — Part 1: Overview & Architecture As someone who is trying to Develop an engineering mindset, this article strongly resonated with the struggles I have faced trying to understand software development from a systems first perspective rather than language first. This is good advice. Github Copilot helped us cut down 50-75% time in our e-commerce business [Boost] md - context menu I'm 11 Years Old. Last Week I Launched My First SaaS. Here's What Actually Happened. How I wire Mux video into a Next.js + Sanity CMS upload workflow Designing Permission Systems Beyond RBAC (ABAC) I'm building an invoicing SaaS for South African freelancers & small agencies — here's where I am so far The Future class in Dart Building a Lightweight Crypto Trading Monitor: From Idea to Open Source Stop posting boring black-and-white screenshots of your code. I built a free tool to fix this. The Mind of Ada Lovelace: How a Victorian Woman Invented the Future of Coding Why Real Browser Automation Is Replacing Simple HTTP Scraping Ambastha Diagrams: A Beta Tool for Easy Diagramming in VS Code Cache-Aware Spawning: What Changed in llm-cli-gateway, a Week On The Best AI Development Tools in 2026: GitHub Copilot vs Cursor vs Claude for Coding Design to Code #8: The Cosmetics of Modularity I just published Part 1 of "The Machine Learning Engineering Series", where I break down the full lifecycle: how raw data becomes a trained model, gets containerised, and ships as a live API that other engineers can actually build on. Debugging Human Hardware: A Developer’s Guide to Optimizing the Dopamine Loop The AI Development Life Cycle (AIDLC): Why Your ML Projects Need More Than SDLC A Practical Guide To Entity Resolution in Python (No Database, No Machine Learning) async/await Finally Made Sense When I Stopped Treating It as Something New Deploy a Secure Containerized App on Amazon ECS Fargate Using ECR and Secrets Manager The Machine Learning Engineering Series I compared every MCP server monetization platform — only one needs zero signup You Don’t Need Microservices (Yet): A Reality Check for Devs What is DevRel? (And Why You Might Already Be One) Enterprise AI Without an Enterprise Budget
Embed Mermaid in Notion: The 4 Working Approaches in 2026
Levi Liu · 2026-05-26 · via DEV Community

TL;DR
Notion has native Mermaid in code blocks now, but the default look is the same pastel render you've seen everywhere, and there's no theme override. This post walks through the four approaches that actually work in 2026 — native code block, static image upload, public hot-linkable image, and live-updating embed — with a comparison table at the end so you can pick by trade-off. There's a shortcut at the 70% mark if you'd rather skip the maintenance.

Why this article exists

Two years ago, "embed Mermaid in Notion" was a search query that returned twenty Stack Overflow threads and zero working answers. Then Notion shipped native mermaid code-block rendering, and the question went quiet.

But the question didn't go away — it shifted. The native renderer works, but it gives you exactly one look: Mermaid's default theme, no overrides, no themeVariables honored. The moment you want your team's Notion docs to feel like a finished product instead of a hackathon scratchpad, you're back to needing a workaround.

There are four of them. Each makes a different trade between live-updating, aesthetic control, and how much pipeline you're willing to maintain.

The four approaches at a glance

Approach Live updates Theme control Maintenance
1. Native mermaid code block None
2. Static image upload Manual re-upload
3. Public hot-linkable image ✅* Host the image
4. Live embed via /embed Host the endpoint

* Live updates only if the source URL serves a fresh render each time.

The rest of this post is just the details under each row.

Approach 1: Native mermaid code block

The cheapest path. Type /code, set the language to Mermaid, paste your source.

flowchart LR
  A[Client] --> B{Auth?}
  B -->|Yes| C[API]
  B -->|No| D[Login]

Enter fullscreen mode Exit fullscreen mode

Notion renders it live. You can edit the source, the diagram re-renders. Free, zero pipeline.

What you give up:

  • No theme override. The %%{init: {...}}%% directive is silently stripped in Notion's renderer. You get default Mermaid pastels whether you want them or not.
  • No <picture> for dark mode. Notion's dark/light switch doesn't tell Mermaid anything; the diagram stays one fixed palette.
  • No PDF export fidelity. When you export the Notion page to PDF, the Mermaid block renders as a raster snapshot, often at a lower resolution than the page expects.

Use this for: internal scratch docs, RFCs, anything where "the diagram exists" is the bar.

Don't use this for: public-facing docs, customer-shared Notion pages, anything you'd want to look intentional.

Approach 2: Static image upload

Render the diagram to SVG or PNG offline, then drag the file into Notion. It becomes an Image block; Notion hosts it on its own CDN.

# Official Mermaid CLI
npx @mermaid-js/mermaid-cli -i flow.mmd -o flow.svg -t base

Enter fullscreen mode Exit fullscreen mode

Drag flow.svg into the Notion page. Done.

Pros: full theme control (you're rendering it yourself), works in PDF export, looks identical light and dark.

Cons: no live updates. Edit the Mermaid source, you re-render the file, you re-upload it. For a doc with five diagrams that change quarterly, this is fine. For a system architecture page that drifts weekly, it's a paper cut.

A subtle gotcha: Notion strips SVG <script> tags and external font references on upload. If your SVG depends on a webfont link in <defs>, the text falls back to Notion's default font. Inline the font with font-family: -apple-system, system-ui, sans-serif to avoid the mismatch.

Approach 3: Public hot-linkable image

Host the SVG somewhere public, then in Notion: /imageEmbed link → paste the URL. Notion fetches it on every page load.

This is the sweet spot for repos that already commit their diagrams as SVG. The pattern:

  1. Render the diagram into your repo: diagrams/auth-flow.svg
  2. Commit and push.
  3. In Notion, embed: https://github.com/<org>/<repo>/raw/main/diagrams/auth-flow.svg

Notion will fetch the URL each time the page loads. Push a new SVG to main, the embed updates within a few minutes (GitHub's raw CDN has a short TTL).

The catch: GitHub's raw.githubusercontent.com serves with Content-Type: text/plain, which some browsers refuse to render as an image. The reliable trick is to route through https://github.com/<org>/<repo>/raw/main/... (no raw. prefix), which redirects to a properly typed CDN response. Notion handles this redirect correctly.

Other hosts work too — Cloudflare R2, S3 with a public bucket, any static CDN. The constraint is just: serve image/svg+xml, allow Notion's user-agent, and don't gate behind auth.

Approach 4: Live embed via /embed + hosted SVG endpoint

The most flexible — and the most pipeline. Use Notion's /embed block (which accepts any URL) to point at an endpoint that renders the Mermaid source on demand.

/embed → https://your-domain.com/render?source=<encoded-mermaid>&theme=atlas

Enter fullscreen mode Exit fullscreen mode

The endpoint does what Mermaid CLI does, but server-side, and returns image/svg+xml. You can pass theme parameters in the query string, regenerate on every request, and the diagram in Notion always reflects whatever the endpoint serves right now.

A barebones version in 50 lines of Node:

import express from "express";
import { run } from "@mermaid-js/mermaid-cli";
import fs from "fs/promises";

const app = express();

app.get("/render", async (req, res) => {
  const source = Buffer.from(req.query.source as string, "base64").toString("utf8");
  const tmpIn = `/tmp/${Date.now()}.mmd`;
  const tmpOut = tmpIn.replace(".mmd", ".svg");

  await fs.writeFile(tmpIn, source);
  await run(tmpIn, tmpOut, { puppeteerConfig: { args: ["--no-sandbox"] } });

  const svg = await fs.readFile(tmpOut, "utf8");
  res.type("image/svg+xml").send(svg);
});

app.listen(3000);

Enter fullscreen mode Exit fullscreen mode

This is the "I want full control" path. You're now running a renderer. That means:

  • A box (Lambda, Cloud Run, a Fly machine) running Chromium for Puppeteer
  • A cache layer so identical sources don't re-render on every Notion poll
  • A timeout policy so a malformed source doesn't hang
  • Some auth or rate limiting so the endpoint doesn't become someone else's free render farm

For a team that already has infra, the 80% solution above is a weekend project. For a solo dev, it's the moment you ask whether the time is worth it.

When DIY stops being worth it

Three signals it's time to stop hand-rolling the Notion pipeline:

  1. You have more than ~10 diagrams across your Notion workspace and you're losing track of which ones are stale.
  2. You want a theme that matches your company's docs site, not Mermaid's defaults.
  3. The team's non-engineers want to make and edit diagrams without learning Mermaid or your render endpoint.

The shortcut: Paste, pick a theme, embed

Beauty Diagram is a web editor for Mermaid, PlantUML, and draw.io. Paste your source, pick from 9 production themes, get a hot-linkable URL that updates when you edit. Drop the URL into Notion's /embed block and it stays live. (Disclosure: I work on it.)

→ Try the editor


The web flow for Notion specifically:

  1. Paste your Mermaid source into the editor.
  2. Pick a theme from nine: classic, modern, atlas, blueprint, memphis, obsidian, slate, brutalist, atelier. Each is a complete design language — palette, typography, edge style, node treatment — tuned so the embed reads as a finished asset.
  3. Save & Share — generates a public URL with a 12-char token.
  4. In Notion, /embed and paste the share URL's .svg form, e.g. https://api.beauty-diagram.com/v1/share/<token>.svg. The embed re-fetches on each page load; if you edit the share, Notion shows the new version within ~5 minutes.

If you'd rather automate from a CLI — say, a CI job that regenerates every diagram in your repo on each release — the same render pipeline is one command:

# Render and get a hot-linkable URL in one shot
npx @beauty-diagram/cli embed-url flow.mmd --theme atlas --share
# → https://api.beauty-diagram.com/v1/share/<token>.svg

Enter fullscreen mode Exit fullscreen mode

bd embed-url --share saves the diagram first, then prints the share-resource SVG URL. Drop that URL directly into a Notion /embed block, or any other surface that accepts an image URL. Re-running on the same file replaces the share contents in place, so the URL is stable and the embed picks up the update automatically.

The CLI exposes the same nine themes (bd themes lists them). It does not expose per-property style overrides — the philosophy is that the theme is the choice; you don't tune a theme, you pick a different one.

Picking the right approach for your page

A rough decision tree:

  • Throwaway internal doc? Native code block. Five seconds, zero pipeline.
  • Quarterly architecture review that gets exported to PDF? Static SVG upload. Manual, but PDF-safe.
  • Diagrams that already live in your repo? GitHub raw URL embed via /image. Free, auto-updates on push.
  • Customer-facing Notion page, or a team doc that drifts weekly? Live embed against a hosted endpoint. Either roll your own, or use a service.

The trap to avoid: picking the most powerful approach for every diagram. Native code blocks are fine when "the diagram exists" is the bar — don't over-engineer them.

Wrap-up

The four approaches, recapped:

  • Native mermaid code block — free, live, but locked to Mermaid defaults.
  • Static image upload — full control, but no live updates.
  • Public hot-linkable image — live and themed, but you host the SVG.
  • Live embed via /embed — full pipeline, full control, the most work.

If this was useful, drop a ❤️ and follow — I'm posting weekly on diagrams, docs, and developer ergonomics. Next week: Mermaid vs PlantUML in 2026 — which to pick for engineering docs.

What's your team's Notion diagram setup — native blocks, static uploads, or something else? Drop a note in the comments; I'm collecting setups for a follow-up.