CLI
npm install -g yuhwa # or run: npx yuhwa <command>pnpm add -g yuhwa # or run: pnpm dlx yuhwa <command>A global install adds two commands, yu and yuhwa, which are the same program.
In a project that has yuhwa installed, npx yuhwa runs that installed version. pnpm dlx yuhwa always fetches the latest release. Use pnpm exec yuhwa for the project's version.
| command | does |
|---|---|
yuhwa <file> | same as yuhwa render <file> |
yuhwa render <file|-> [-o out.svg] [--theme name] | render to SVG, HTML or PNG |
yuhwa check <file...> [--json] [--lang a,b] | validate without rendering |
yuhwa lint <file...> [--fix] [--json] | check plus hygiene and format |
yuhwa convert <file|-> [-o out.yu] | Mermaid or JSON to yuhwa |
yuhwa md <file.md...> | render blocks in Markdown |
yuhwa edit <file> [--block n] | open the visual editor |
yuhwa serve, yuhwa url <file> | HTTP render service and its URLs |
yuhwa guide (alias llms) | language reference for AI agents |
yuhwa themes | list themes |
yuhwa -v, yuhwa -h | version, help |
Every command that reads a diagram accepts yuhwa, a Mermaid flowchart or JSON. The format is detected from the content. Pass - to read from stdin.
Imports only read .yu files.
import "./other.yu" lines are read from disk, relative to the file that imports them. From stdin, they resolve against the current directory. See Imports.
render
yuhwa render diagram.yu -o diagram.svg [--theme midnight]
yuhwa render - < diagram.yu > diagram.svgWrites the SVG to stdout unless -o is given. --theme overrides the theme: setting.
--html, or an -o path ending in .html, writes a page instead: the diagram in a full-window pan and zoom viewer, with no files to load.
yuhwa render big.yu -o big.html--png, or an -o path ending in .png, writes a PNG. --scale n sets the pixels per SVG unit (default 2). PNG output needs the optional @resvg/resvg-js package, since Node has no canvas:
npm install -D @resvg/resvg-js
yuhwa render diagram.yu -o diagram.png --scale 3pnpm add -D @resvg/resvg-js
yuhwa render diagram.yu -o diagram.png --scale 3The PNG uses fonts installed on the system. --font adds a font file or a folder of them, and can be repeated. --no-system-fonts uses only those fonts. See Fonts.
Without installing anything, npx or pnpm dlx can fetch both packages for one run:
npx -p yuhwa -p @resvg/resvg-js yuhwa render diagram.yu -o diagram.pngpnpm --package=yuhwa --package=@resvg/resvg-js dlx yuhwa render diagram.yu -o diagram.pngFrom a Markdown file, render draws one block. --block n picks it, counting from 0. The default is the first block.
yuhwa render README.md --block 1 -o second.svgcheck
yuhwa check diagram.yu
yuhwa check docs/*.yu
yuhwa check diagram.yu --jsonValidates without rendering and takes several files. Each file gets a file: ok (yuhwa, N diagnostic(s)) summary line. Warnings and errors go to stderr as file:line: severity: message. --json prints a machine-readable report to stdout:
{
"file": "diagram.yu",
"ok": true,
"format": "yuhwa",
"nodes": 2,
"edges": 1,
"groups": 0,
"diagnostics": [{ "line": 1, "severity": "warning", "message": "Unknown color \"bleu\" (did you mean \"blue\"?)" }]
}With several files, --json prints an array of these reports.
Markdown files
yuhwa check README.md docs/*.md
yuhwa check docs/*.mdx --lang yuhwa,yu,mermaidA .md, .mdx or .markdown file is checked block by block. These blocks count:
- fences in the languages
yuhwaandyu; <!--yuhwa name … -->comments, as written byyuhwa md.
--lang replaces the fence languages, comma-separated. Fences with no-render are skipped, like the docs integrations skip them. A fence in another language is skipped with everything inside it, so a ```markdown fence that shows a yuhwa block is not checked.
Line numbers point into the Markdown file. The summary line reads file.md: ok (markdown, N block(s), N diagnostic(s)). A page without blocks is ok and says no yuhwa blocks found.
--json prints one report per Markdown file. It has the same keys, with format: "markdown" and the counts summed over all blocks. Each diagnostic also has block, the block's index. blocks lists every block:
{
"file": "README.md",
"ok": false,
"format": "markdown",
"nodes": 5,
"edges": 2,
"groups": 0,
"diagnostics": [{ "line": 15, "message": "…", "severity": "error", "block": 1 }],
"blocks": [
{
"index": 0,
"lang": "yuhwa",
"name": "checkout",
"line": 3,
"ok": true,
"format": "yuhwa",
"nodes": 2,
"edges": 1,
"groups": 0
},
{ "index": 1, "lang": "yu", "line": 13, "ok": false, "format": "yuhwa", "nodes": 3, "edges": 1, "groups": 0 }
]
}line is the line of the opening fence. lang is comment for a <!--yuhwa --> block. A page without blocks has blocks: [] and note: "no yuhwa blocks found".
render and check exit with status 1 when the source has errors. Warnings do not change the exit status, but they point at real mistakes: a node renamed by an edge, a node moved between groups, a layout line for a node that no longer exists, an edge to a misspelled node id. Fix them too.
lint
yuhwa lint docs/*.yu README.md
yuhwa lint diagram.yu --fixlint reports everything check does, plus things that render fine but should not stay in the file:
- a class,
$variableordefcomponent that is never used; - the same edge drawn twice;
- a
.yufile, or a diagram block in Markdown, that is not formatted.
A file that draws nothing is a library for imports, so its definitions count as used. So does anything it exports.
lint exits with status 1 on any finding, warnings included, which makes it fit for CI and pre-commit hooks. --fix formats .yu files in place; the other findings name their fix. Markdown files are linted block by block, like check, and --fix formats their ```yuhwa blocks and <!--yuhwa comments, leaving the rest of the page as it is. no-render blocks and JSON blocks are not touched. --json prints { file, ok, diagnostics }, with fixed: true when the file was formatted.
The language server shows the same findings as hints in the editor. Unused definitions are greyed out.
convert
yuhwa convert flow.mmd -o flow.yu
yuhwa convert diagram.jsonTurns a Mermaid flowchart or a JSON diagram into yuhwa source.
md
yuhwa md README.md docs/*.md [--out-dir diagrams] [--dark] [--keep-fences] [--view[=base]]--view links each image to a pan and zoom viewer of the diagram. See Zoom and pan on GitHub.
Renders every yuhwa block in Markdown files. See Markdown and GitHub.
edit
yuhwa edit diagram.yu [--port 4747] [--no-open]
yuhwa edit README.md --block 1Opens the visual editor on a local file. Saving writes back into the file and into imported .yu files you changed. --block n picks the n-th diagram (from 0) in a Markdown file.
serve and url
yuhwa serve [--port 4749] [--host 127.0.0.1]
yuhwa url diagram.yu [--base http://localhost:4749] [--view]The HTTP render service and its image URLs. See Image URLs. url --view prints a link to a pan and zoom viewer instead: the hosted one, or /yuhwa/view/… on your server with --base.
guide and themes
yuhwa guide # the language reference, written for AI agents (alias: llms)
yuhwa themes # list the themes