Getting started
yuhwa turns a few lines of text into an SVG diagram. This page takes you from nothing to a rendered diagram, editor support and diagrams in your docs in about five minutes.
Try it in the browser
No install needed: open the visual editor, type on the left and the diagram updates on the right. Your diagrams stay in local storage. Import converts Mermaid or JSON, Share copies a link with the source in the URL.
Every diagram on this site has an Open in editor link in its corner.
Install
yuhwa needs Node.js 22 or later.
npm install -g yuhwa
yu --version # `yuhwa` works toopnpm add -g yuhwa
yu --version # `yuhwa` works tooPrefer not to install globally? Put npx yuhwa (or pnpm dlx yuhwa) in front of every command instead of yuhwa, or add it to a project with npm install -D yuhwa (or pnpm add -D yuhwa).
Your first diagram
Create a file hello.yu:
web "Web app" -> api "API" -> db "Postgres" [cylinder]
api -> cache "Redis": read-through [dashed]Render it:
yuhwa render hello.yu -o hello.svgOpen hello.svg in a browser. That's it.
What the two lines mean:
- Each line is one statement.
web "Web app"declares a node: an id (web) and a label ("Web app"). A one-word node needs no label:web -> api.->draws an edge.a -> b -> cmakes two.- Props go in square brackets:
[cylinder]. A bare value names its key, so[cylinder]means[shape: cylinder]. - Edge labels and edge props go after a colon:
: read-through [dashed].
Check for mistakes
yuhwa check validates a file without rendering it. Misspell a colour, say db "Postgres" [cylinder, color: bleu], and check:
$ yuhwa check hello.yu
hello.yu:1: warning: Unknown color "bleu" (did you mean "blue"?)
hello.yu: ok (yuhwa, 1 diagnostic(s))Errors exit with status 1, so check works in CI and pre-commit hooks. Warnings do not fail, but they point at real mistakes: fix them too.
Edit it visually
yuhwa edit hello.yuThis opens the editor on your file. Drag boxes, bend edges, move labels. ⌘S (Ctrl+S) saves back to hello.yu; hand-placed positions go into a small layout { } block at the end. See Visual editor.
Grow the diagram
Add colour, groups and a direction. Classes (.svc) name a look once:
title: Orders
direction: down
.svc [blue]
group app "Application" {
api "API" .svc
worker "Worker" .svc
sub: jobs
}
api -> worker: enqueue
api, worker -> db "Postgres" [cylinder, amber]title:anddirection:are settings, one per line.group id "Label" { … }draws a box around nodes.- An indented line under a node adds a prop:
sub: jobsis a second line of text. a, b -> cdraws an edge from each.
The cheatsheet fits the whole language on one page. Syntax has every statement and prop.
More than boxes and arrows
Sequence diagrams, timelines, charts, git histories, mind maps, Gantt charts, quadrants and kanban boards are panels. They go in the same file and line up next to the graph:
title: Release 1.1
web "Web" [blue] -> api "API" [blue]
git release "Branches" {
commit "1.0" [tag: v1.0]
branch feature/search
commit "search"
checkout main
merge feature/search [tag: v1.1]
}Diagram types has a page for every panel kind, and Combining diagrams covers arranging them and import, which splits a diagram over several files. The examples show them in use.
Set up your editor
Get diagnostics, completion, hover and rename while you type:
VS Code, Cursor, VSCodium: install the yuhwa extension. It bundles the language server. See VS Code.
Neovim, Helix, Sublime, Emacs, JetBrains, Vim, Kate: install the language server and add a few lines of config:
shnpm install -g yuhwashpnpm add -g yuhwaThen follow the snippet for your editor in Language server.
Put diagrams where you need them
| you want | use |
|---|---|
| diagrams in a GitHub or GitLab README | yuhwa md writes SVGs next to the file |
| diagrams in a docs site (VitePress, VuePress, Starlight, Docusaurus, Vocs, Nextra …) | a build plugin, one line of config |
| diagrams on any web page | the script tag or web component |
.yu files in a React, Vue or Svelte app | the Vite plugin |
| diagrams in wikis, chat or issue trackers | the render service and plain image URLs |
| SVG from JavaScript | render() |
| an AI agent that writes diagrams | yuhwa guide and yuhwa check --json |
| to move off Mermaid | yuhwa convert |
The fastest of these, for a README:
```yuhwa
client "Client" -> server "Server": HTTPS
```yuhwa md README.mdThe block becomes a hidden comment and an image link to diagrams/readme-1.svg, which GitHub shows like any picture. Edit the comment and run yuhwa md again to update it.