Skip to content

CLI ​

sh
npm install -g yuhwa   # or run: npx yuhwa <command>
sh
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.

commanddoes
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 themeslist themes
yuhwa -v, yuhwa -hversion, 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 ​

sh
yuhwa render diagram.yu -o diagram.svg [--theme midnight]
yuhwa render - < diagram.yu > diagram.svg

Writes 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.

sh
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:

sh
npm install -D @resvg/resvg-js
yuhwa render diagram.yu -o diagram.png --scale 3
sh
pnpm add -D @resvg/resvg-js
yuhwa render diagram.yu -o diagram.png --scale 3

The 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:

sh
npx -p yuhwa -p @resvg/resvg-js yuhwa render diagram.yu -o diagram.png
sh
pnpm --package=yuhwa --package=@resvg/resvg-js dlx yuhwa render diagram.yu -o diagram.png

From a Markdown file, render draws one block. --block n picks it, counting from 0. The default is the first block.

sh
yuhwa render README.md --block 1 -o second.svg

check ​

sh
yuhwa check diagram.yu
yuhwa check docs/*.yu
yuhwa check diagram.yu --json

Validates 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:

json
{
  "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 ​

sh
yuhwa check README.md docs/*.md
yuhwa check docs/*.mdx --lang yuhwa,yu,mermaid

A .md, .mdx or .markdown file is checked block by block. These blocks count:

  • fences in the languages yuhwa and yu;
  • <!--yuhwa name … --> comments, as written by yuhwa 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:

json
{
  "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 ​

sh
yuhwa lint docs/*.yu README.md
yuhwa lint diagram.yu --fix

lint reports everything check does, plus things that render fine but should not stay in the file:

  • a class, $variable or def component that is never used;
  • the same edge drawn twice;
  • a .yu file, 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 ​

sh
yuhwa convert flow.mmd -o flow.yu
yuhwa convert diagram.json

Turns a Mermaid flowchart or a JSON diagram into yuhwa source.

md ​

sh
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 ​

sh
yuhwa edit diagram.yu [--port 4747] [--no-open]
yuhwa edit README.md --block 1

Opens 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 ​

sh
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 ​

sh
yuhwa guide    # the language reference, written for AI agents (alias: llms)
yuhwa themes   # list the themes

Released under the MIT License.