Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Usage Guide

Kroki-rs can be used in two modes: CLI (Command Line Interface) and Server (HTTP API).

CLI Mode

Use the CLI for one-off conversions or batch processing scripts.

Command Structure

kroki-rs convert --type <DIAGRAM_TYPE> --format <OUTPUT_FORMAT> <INPUT_FILE>

Batch Conversion

Have a folder full of diagrams? Kroki-rs can convert them all concurrently:

kroki-rs batch -f webp --out-dir ./output ./my-diagrams

Kroki-rs will automatically detect the diagram type from the file extension (e.g., .mmd -> mermaid, .d2 -> d2).

CLI Examples

Click to view conversion examples for all supported types
Graphviz
Mermaid
D2
BPMN
Wavedrom
Ditaa
Excalidraw
Vega
Vega-Lite

Command:

kroki-rs convert -t graphviz -f svg tests/fixtures/test.dot > output.svg

Server Mode

The server CLI follows the Kroki API specification.

Start Server

kroki-rs serve [--port <PORT>]

Default port is 8000.

API Endpoints

GET /:type/:format/:source_encoded

Generates a diagram from an encoded source string.

Example: Request a Graphviz diagram:

curl http://localhost:8000/graphviz/svg/eNpLyUwvSizm5TIGAAWDAY0=

POST /

(If implemented) Accepts a JSON payload with diagram source and type.

{
  "diagram_source": "digraph G { Hello -> World }",
  "diagram_type": "graphviz",
  "output_format": "svg"
}

Admin Dashboard & Health Checks

When running in Server Mode, Kroki-rs automatically exposes an Admin Dashboard on an isolated port (default: 8081). This completely separates administrative capabilities from the primary diagram rendering APIs.

Supported Clients

Since kroki-rs is API-compatible, you can use existing Kroki clients! Just point them to your local instance.

Debugging & Troubleshooting

Enabling Verbose Logs

If a diagram fails to render, the first step is to increase the logging level:

# For CLI
RUST_LOG=debug kroki-rs convert -t mermaid -f svg test.mmd

# For Server
RUST_LOG=debug kroki-rs serve

Checking Capabilities

Kroki-rs skips diagram providers if their underlying tools are missing. Verify your installation by running the discovery check:

kroki-rs serve --dry-run

This will print the discovery log without starting the server, showing which tools were found and where.

Browser Worker Debugging

For diagrams using the browser pool (Mermaid, BPMN), ensure your system has a compatible Chromium/Chrome binary. If running on a headless server without a window manager, ensure Xvfb is installed or use the official Docker Image which handles these dependencies automatically.