From Mermaid or JSON
Every API and CLI command accepts three input formats and detects the format from the content.
Mermaid
Mermaid diagrams render as they are. Flowcharts become a yuhwa graph. Most other diagram types become a panel or nodes and groups:
flowchart LR
A[Start] --> B{Valid?}
B -->|yes| C((Done))
B -.->|no| D[(Error log)]
subgraph svc [Service]
C
endConvert one to yuhwa source to restyle it:
yuhwa convert flow.mmd -o flow.yuWhat converts
| Mermaid | yuhwa |
|---|---|
graph, flowchart | nodes, edges and groups |
stateDiagram, stateDiagram-v2 | nodes and groups. [*], fork, join and choice states get small classes such as .state-start. Composite states become groups |
classDiagram | card nodes (attributes, ---, methods). Inheritance, composition and dependency become edges with head/tail markers. Cardinalities become the edge caption. Namespaces become groups |
erDiagram | an entity block becomes a node with a type | name | keys | comment table. A relationship becomes an edge with the cardinality as caption |
sequenceDiagram | sequence panel |
timeline | timeline panel |
gitGraph | git panel |
pie | chart panel, type: pie |
xychart-beta | chart panel, bar or line |
journey | chart panel, one column per task score, coloured by score |
mindmap | mindmap panel |
gantt | gantt panel |
quadrantChart | quadrant panel |
kanban | kanban panel |
The gantt, quadrant and kanban panels come from plugins. Register a plugin with use() before you render its panel.
Flowchart details:
| Mermaid | yuhwa |
|---|---|
TD TB LR RL BT | direction |
A[x] A(x) | default shape |
A{x} A A[(x)] A((x)) A([x]) A[/x/] | diamond, hexagon, cylinder, circle, pill, parallelogram |
--> --- -.-> ==> <--> | -> -- ..> => <-> |
-->|label| and -- label --> | edge label |
subgraph id [Title] … end | group |
classDef, class, :::name, style | classes and props |
Mermaid style and classDef colours pass through: fill and stroke keep their hex or rgb() value. Mermaid's color is the text colour, so it becomes text. yuhwa's own color prop sets the palette colour of a node.
What gives a warning
The converter keeps going and lists what it skipped or changed:
click,linkStyle,accTitleandaccDescrare skipped.- A
directioninside a subgraph or composite state is skipped. - Sequence
loop,alt,optandparblocks become--- … ---dividers.rectboxes and activations are skipped. Cross ends (-x) are drawn as normal arrows. - State concurrency regions (
--) are drawn as one region. Edges to a composite state attach to its start or end state inside. - Class aggregation (
o--) is drawn as a diamond, like composition. - Journey actors are skipped. The scores become a column chart.
xychart-betay-axis titles and ranges are skipped; the chart scales to the data.- Mindmap icons and classes are skipped. Cloud, bang and hexagon shapes use the default look.
- Gantt
excludes, adateFormatother thanYYYY-MM-DD, and lengths in seconds or minutes are approximated. - Kanban priority
Very Highbecomeshigh,Very Lowbecomeslow.
What gives an error
These types have no yuhwa equivalent yet: sankey-beta, C4Context and the other C4 types, requirementDiagram, packet-beta, block-beta, architecture-beta, radar-beta, treemap-beta and zenuml.
What yuhwa does better
| Mermaid | yuhwa |
|---|---|
styles repeat on every node, or need classDef plus class lines | .svc [blue] once, .primary .svc [bold] to extend |
| colours are CSS strings per diagram type | one palette everywhere: [red], [color: teal], or a hex, rgb() or hsl() value |
| no variables | $brand: violet, then color: $brand anywhere |
| no reuse of node patterns | def service(id, label) { … }, then service(cart, "Cart") |
| one file per diagram | import, with export lists and import { a as b } |
| one diagram type per block | a graph and any number of panels (sequence, chart, git, gantt, …) in one file |
| positions cannot be fixed | drag in the editor; positions land in a layout { } block |
| a gantt task needs an id and a date format | design "Design": 2024-01-01, 10d, and the next task follows on its own |
kanban metadata is a YAML-like @{ } block | chips: - Fix login [owner: ana, priority: high] |
| a class or ER diagram is its own syntax | they are ordinary nodes, so classes, groups and themes apply |
| errors stop the render | warnings with line numbers and did you mean hints; the rest still renders |
JSON
Programs and tool-calling models can send structured data instead of text. The object has optional title, direction, theme, settings, classes, groups, nodes and edges keys. Any other key on a node, edge or group is a prop.
{
"title": "Checkout",
"direction": "down",
"classes": { "svc": { "color": "blue" } },
"groups": [{ "id": "core", "label": "Core", "color": "slate" }],
"nodes": [
{ "id": "api", "label": "API", "group": "core", "class": "svc", "sub": "Node 22" },
{ "id": "db", "label": "Postgres", "shape": "cylinder" }
],
"edges": [{ "from": "api", "to": ["db", "cache"], "label": "read", "arrow": "-->" }]
}groups[].parentnests a group in another one.edges[].fromandedges[].totake an id or a list of ids (fan-out).edges[].arrowis one of the arrows. The default is->.classtakes a name or a list of names.
render() also accepts the object directly. yuhwa convert diagram.json prints the equivalent yuhwa source.
In the editor
Import in the visual editor takes Mermaid, JSON or yuhwa: paste it, pick a file, or drop one on the window. The editor converts it and opens the result as a new file tab, or replaces the current one. A Markdown file works too: the first yuhwa, mermaid or json fence is imported.