canonical: https://jentic.com/apis/kroki.io/kroki

# Kroki API

The Kroki API renders diagrams from plain-text descriptions, turning Mermaid, PlantUML, Graphviz, D2, BPMN, Excalidraw, Vega-Lite, and 25 more diagram languages into images. Each diagram type has its own path: POST the source as the request body, or GET it with the source compressed with deflate and encoded as URL-safe base64 in the path, and choose an output format such as svg, png, or pdf where the library supports it. Diagram options such as theme, scale, or layout go in query parameters or Kroki-Diagram-Options headers, and errors come back as JSON with a type such as diagram-error plus the line and column the diagram library reports. The spec describes the public instance at kroki.io, where no authentication is declared.

## For AI agents

Render Mermaid, PlantUML, Graphviz, D2, and other text diagram languages to SVG, PNG, or PDF with a single HTTP call, using library-specific options and line-numbered error reports.

## Scope

Does not store, edit, version, or share diagrams, and does not convert existing image or document files. Use for rendering text diagram source into SVG, PNG, PDF, or text output only.

## Capabilities

- Render a diagram from its text source by POSTing it to the path for its type, such as `/mermaid/svg` or `/plantuml/png`
- Pick the diagram type at request time with POST / and a JSON body of diagram_source, diagram_type, and output_format
- Build shareable image URLs by compressing the source with deflate and URL-safe base64 into the source_encoded path segment of a GET request
- Tune output per library with query options such as theme and scale for PlantUML, layout and sketch for D2, or layout for Graphviz
- Read structured JSON errors whose type distinguishes diagram-error, unsupported-format, and uri-too-long, with the line and column of a syntax problem
- Check the instance and the version of each diagram library through the /health endpoint, and scrape Prometheus metrics from /metrics

## Use cases

### AI agent drawing diagrams on request

An agent asked to explain a system writes the diagram as Mermaid or PlantUML text, searches Jentic for 'render a Mermaid diagram as SVG', and calls the matching Kroki operation such as postMermaidInFormat with the source as the body. Kroki returns the rendered SVG, so the agent can attach a real image instead of a code block, and if the source is invalid the JSON error names the line and column to fix before retrying.

Example prompt: POST a Mermaid flowchart source as the request body to `/mermaid/svg` and save the returned image/svg+xml response as architecture.svg

### Diagrams-as-code in documentation pipelines

Docs written in Markdown or AsciiDoc often keep diagrams as PlantUML, Graphviz, or Structurizr source. A build step sends each block to the Kroki path for its type and output format, for example `/plantuml/svg` or `/structurizr/png`, and embeds the returned image, so the rendered docs stay in step with the diagram source in the repo. PlantUML and C4-PlantUML also support pdf, txt, and utxt outputs.

Example prompt: POST a PlantUML component diagram to `/plantuml/pdf` and store the returned application/pdf file alongside the docs build output

### Shareable diagram image URLs

For a README, an issue, or a chat message, a GET link is easier to share than a file. Compress the diagram source with deflate (zlib), encode it as URL-safe base64, and place it in the source_encoded segment of a path such as `/graphviz/svg/{source_encoded}.` Anyone who opens the link gets the rendered image, and very long sources return a uri-too-long error, at which point the POST form is the fallback.

Example prompt: Deflate and URL-safe base64 encode a dot graph, then GET `/graphviz/svg/{source_encoded}` with it and return the URL for use in a README

### One endpoint for many diagram languages

Tools that accept user-written diagrams in many languages can send every one to POST / with a JSON body naming diagram_type, such as mermaid, d2, wavedrom, or vegalite, plus diagram_source and output_format. That keeps a single code path for all 32 diagram types the spec enumerates, while per-type options travel in diagram_options.

Example prompt: POST / with diagram_type d2, output_format svg, and diagram_source containing a D2 graph, then return the rendered SVG

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/` | Render a diagram whose type is named in the JSON body |
| POST | `/mermaid/{output_format}` | Render a Mermaid diagram to SVG or PNG |
| POST | `/plantuml/{output_format}` | Render a PlantUML diagram to SVG, PNG, PDF, or text |
| POST | `/graphviz/{output_format}` | Render a Graphviz diagram |
| POST | `/d2/{output_format}` | Render a D2 diagram |
| GET | `/mermaid/{output_format}/{source_encoded}` | Render a Mermaid diagram encoded in the URL |
| GET | `/health` | Health check with diagram library versions |

## Key resources

- **Diagram types** — 32 text diagram languages, each with its own path, such as mermaid, plantuml, graphviz, d2, bpmn, and excalidraw
- **Output formats** — Per-type formats such as svg, png, pdf, base64, txt, or utxt, given in the path, the output_format query parameter, or the Accept header
- **Encoded source** — Diagram source compressed with deflate (zlib) and URL-safe base64 encoded for GET requests
- **Diagram options** — Library-specific settings passed as query parameters, Kroki-Diagram-Options headers, or diagram_options in the JSON body
- **Errors** — JSON error object with code, type, message, and the line and column of a diagram syntax problem

## AI readiness

This API is usable in Jentic One now. Its AI-readiness score against Jentic's framework shows where it stands today and where improvements would make it even easier for agents to use.

- **Score:** 66 / 100
- **Maturity:** AI-Aware
- **Dimensions:**
  - Foundational Compliance: 80 / 100
  - Developer Experience & Jentic Compatibility: 62 / 100
  - AI-Readiness & Agent Experience: 48 / 100
  - Agent Usability: 84 / 100
  - Security: 100 / 100
  - AI Discoverability: 56 / 100
- **View full report:** https://jentic.com/apis/kroki.io/kroki/scorecard
- **How the score is calculated:** https://docs.jentic.com/reference/api-readiness-framework/overview/
- **More about the dimensions:** https://docs.jentic.com/reference/api-readiness-framework/specification/#dimensional-model-overview

### Score it yourself

Every API in the directory is allowlisted, so you can re-score it with no key required.

- **Score your own API:** https://jentic.com/scorecard.md
- **Scoring CLI agent skill:** https://github.com/jentic/jentic-api-scorecard/blob/main/skills/jentic-api-scorecard/SKILL.md

```sh
npx @jentic/api-scorecard-cli score <openapi-url>
```

## Why Jentic

- **Setup:** Wiring Kroki by hand means learning a separate path and format list for each of 32 diagram types, deflating and base64url-encoding sources for GET links, and parsing its JSON error types. Through Jentic you install once, import Kroki from the API Directory, and your agent calls it with no credential to manage.
- **Permission scoping:** Kroki puts the diagram type in the URL path (`/mermaid/...`, `/plantuml/...`), so a rule can hold your agent to the diagram languages and operations you pick. The generic POST / carries the type in its body instead, so leave it out when you want that bound to hold, and the metrics and health endpoints are not included unless you add them.
- **Credential handling:** The Kroki public instance declares no authentication, so there is nothing to store. For any API you add that does use a key, your own Jentic One instance keeps it encrypted and injects it at execution time, out of the agent's prompt, logs, and context.
- **Discovery method:** Agents search Jentic by intent such as 'render a PlantUML diagram as PNG' or 'convert Graphviz to SVG', and Jentic returns the matching Kroki operation with its input schema so the agent calls the right diagram path without browsing the reference docs.

## Related APIs

- **Mermaid API** — Mermaid Chart's own API for Mermaid diagrams and documents
- **QuickChart API** — Render charts and other images from a JSON or text definition
- **Image-Charts** — Generate chart images from URL parameters
- **CloudConvert API** — Convert rendered files between document and image formats

## FAQ

### Does the Kroki API need authentication?

No. The OpenAPI spec for the public Kroki instance declares no security schemes, so render requests are sent without an API key or token. Through Jentic your agent calls it with nothing to store.

### Which diagram types can the Kroki API render?

The spec enumerates 32 diagram types, including actdiag, blockdiag, bpmn, bytefield, c4plantuml, d2, dbml, diagramsnet, ditaa, dot, erd, excalidraw, graphviz, mermaid, nomnoml, pikchr, plantuml, structurizr, svgbob, tikz, vega, vegalite, wavedrom, and wireviz. Output formats differ by type: Mermaid offers png and svg, while PlantUML adds pdf, base64, txt, and utxt.

### How do I put a diagram in a Kroki URL?

Compress the diagram source with deflate (zlib), encode the result as URL-safe base64, and use it as the source_encoded path segment, for example in GET `/mermaid/{output_format}/{source_encoded}.` For large diagrams that would exceed URL limits, POST the source to `/mermaid/svg` instead.

### What are the rate limits for the Kroki API?

The OpenAPI spec does not specify rate limits. Check the Kroki documentation at https://docs.kroki.io for guidance on using the public instance.

### Is there a Kroki MCP server?

You don't need an MCP server to give your agent the Kroki API. Jentic connects it directly from the API Directory: import it and your agent calls the render operation for the diagram type it needs, without loading a separate server's tool definitions into its context.

### How do I render a Mermaid diagram with the Kroki API through Jentic?

Search Jentic for 'render a Mermaid diagram as SVG', load the postMermaidInFormat operation, and execute POST `/mermaid/{output_format}` with svg as the format and the Mermaid source as the body. To run it on your own infrastructure, install Jentic One from its GitHub repo.

### Can I limit what my agent is allowed to do with the Kroki API?

Yes. Write a rule that allows only POST `/mermaid/svg` and POST `/plantuml/svg`, and the agent can render SVG diagrams in those two languages and nothing else, while the metrics endpoint and the other diagram paths stay off its list. Every call it makes is logged.
