dag from-mermaid
Convert a Mermaid flowchart diagram to a .dag.json workflow file. Useful for designing pipelines visually in Mermaid Live Editor and then running them directly.
Synopsis
dag from-mermaid "<mermaid string>" [--output <path>] [--run] [--input key=value] [--dagId <id>]
dag from-mermaid <file.dag.md> [--output <path>] [--run] [--input key=value] [--dagId <id>]Diagram Syntax
Use standard Mermaid flowchart syntax. Node labels in square brackets map to DAG node types. A node written as id[node-type] sets both the node ID and the node type. A node written as just id uses the ID as the type as well.
flowchart LR
input-->llm[llm-text-anthropic]
llm-->output[text-output]Both LR (left-right) and TD (top-down) directions are accepted. Edge labels are ignored.
Inline String
Pass the Mermaid diagram as a quoted string. Use --run to execute immediately after conversion.
dag from-mermaid "flowchart LR
input-->llm[llm-text-anthropic]
llm-->output[text-output]" \
--run \
--input text="Hello, what is the meaning of life?".dag.md File
For longer diagrams, save the Mermaid block inside a .dag.md file and pass the file path as the first argument.
# pipeline.dag.md
```mermaid
flowchart LR
input-->llm[llm-text-anthropic]
llm-->output[text-output]
```dag from-mermaid pipeline.dag.md --output pipeline.dag.jsonGenerated Output
The command writes a standard DAG workflow JSON file that can be run with dag run, inspected with dag explain, or repaired with dag fix.
{
"dagId": "generated-dag",
"nodes": [
{ "id": "input", "type": "input" },
{ "id": "llm", "type": "llm-text-anthropic" },
{ "id": "output", "type": "text-output" }
],
"edges": [
{ "source": "input", "target": "llm" },
{ "source": "llm", "target": "output" }
]
}Flags
| Flag | Description |
|---|---|
| --output <path> | Write the generated .dag.json file to this path. Defaults to stdout if omitted. |
| --run | Execute the generated DAG immediately after conversion. |
| --input <key=value> | Input values passed to the pipeline when --run is set. |
| --dagId <id> | Assign a custom identifier to the generated DAG. |