Skip to content
Go back

Excalidraw Whiteboard: Hand-Drawn Diagrams in Your Blog

Learn how to integrate Excalidraw hand-drawn style whiteboards into your blog posts, including embedding methods, scene URLs, and best practices.

Excalidraw is a virtual whiteboard tool that produces hand-drawn style diagrams. It’s perfect for technical illustrations, architecture diagrams, and visual explanations that feel approachable and informal.


What is Excalidraw?

Excalidraw is an open-source virtual whiteboard with these key features:

It’s widely used in technical blogs, documentation, and architecture design.


Integration Methods

There are two ways to embed Excalidraw in this blog:

Use the :::excalidraw directive directly in any Markdown file:

:::excalidraw{src="https://excalidraw.com/#json=..." height="500px"}
markdown

This directive handles responsive sizing, dark mode, and loading states automatically. No imports needed — works in both .md and .mdx files.

Method 2: iframe Embed (Fallback)

For cases where the directive is unavailable, use an HTML iframe directly:

<iframe
  src="https://excalidraw.com/#json=YOUR_SCENE_DATA"
  width="100%"
  height="500"
  style="border: none; border-radius: 8px;"
  title="Excalidraw Diagram"
></iframe>
html

Using the Excalidraw Directive

The :::excalidraw directive provides the richest integration. Here’s the full API:

:::excalidraw{src="https://excalidraw.com/#json=..." height="500px"}
markdown

Directive Attributes

AttributeTypeDefaultDescription
srcstringrequiredExcalidraw scene URL
heightstring"400px"Height of the embed container

How to Get a Scene URL

  1. Go to excalidraw.com
  2. Create your diagram
  3. Click the Share button (or use Ctrl+Shift+E)
  4. Select Shareable link
  5. Copy the URL — it contains the full scene data encoded in the hash fragment

The URL format looks like:

https://excalidraw.com/#json=eyJlbGVtZW50cyI6W...
plaintext

Live Demo

Here’s an embedded Excalidraw whiteboard using the directive:

Tip

The directive automatically handles lazy loading and responsive sizing. No need to manually add loading="lazy" or width attributes.


Creating Shareable Scenes

Step-by-Step Guide

  1. Open Excalidraw — Navigate to excalidraw.com
  2. Draw your diagram — Use the toolbar to add shapes, arrows, text
  3. Export as link — Click the share icon and choose “Shareable link”
  4. Copy the URL — The scene data is encoded in the URL hash
  5. Paste into your post — Use the :::excalidraw directive with the scene URL

Scene Data Format

Excalidraw encodes scene data as JSON in the URL hash. A minimal scene looks like:

This JSON is then Base64-encoded and appended to the URL as a hash fragment.


Example Scenes

Scene 1: Simple Architecture Diagram

A typical web application architecture with client, server, and database layers:

┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Browser    │────▶│   Server    │────▶│  Database   │
│  (React/Vue) │◀────│  (Node.js)  │◀────│ (PostgreSQL)│
└─────────────┘     └─────────────┘     └─────────────┘
       │                    │
       ▼                    ▼
┌─────────────┐     ┌─────────────┐
│    CDN      │     │    Cache    │
│ (Cloudflare)│     │   (Redis)   │
└─────────────┘     └─────────────┘
plaintext

In Excalidraw, this would be drawn with hand-sketched rectangles and arrows, giving it a friendly whiteboard feel.

Scene 2: Data Flow Diagram

User Input ──▶ Validation ──▶ Processing ──▶ Storage
     │              │              │            │
     ▼              ▼              ▼            ▼
  UI Form      Schema Check   Transform     Database
                   │              │
                   ▼              ▼
               Error Msg     Event Queue ──▶ Notifications
plaintext

Scene 3: Component Hierarchy

           App
          / | \
     Header Main Footer
       |     |      |
     Nav   Content  Links
    / | \    |
  Logo Menu Search
           / | \
      Posts Tags Categories
plaintext

These ASCII representations show the kind of diagrams you’d create in Excalidraw. The hand-drawn style makes them perfect for blog posts where you want to explain concepts without the rigidity of formal UML diagrams.


Tips and Best Practices

Design Tips

Performance Tips

Accessibility Tips

Note

Excalidraw scenes shared via URL are end-to-end encrypted. Only people with the exact link can view the content. The server never sees the unencrypted scene data.


Further Reading



Previous Post
Asciinema Terminal Replay
Next Post
Markdown Basics: A Complete Syntax Guide

评论区

文明评论,共建和谐社区