BYTETOOLS

Kroki API

Free diagram-as-code API with no key: send Graphviz, Mermaid, PlantUML or 25 other diagram languages as text and get back SVG, PNG or PDF. Tested curl example included.

No API key requiredCORS enabledHTTPSFree tier

Endpoint tested and returned HTTP 200 on 2026-08-21

What is the Kroki API?

Kroki is a free, key-free API that turns diagram source text into images. You POST a JSON body containing the diagram source, its language (Graphviz, Mermaid, PlantUML, D2, BPMN and about 25 others) and an output format, and Kroki returns the rendered SVG, PNG or PDF directly.

Kroki solves a problem every documentation site eventually hits: you want diagrams stored as text in Git, but rendering them means installing Graphviz, a JVM for PlantUML, Node for Mermaid and a different binary for every other syntax. Kroki puts all of them behind one HTTP endpoint, so your build pipeline needs nothing but the ability to make a request.

There are two ways to call it. The POST form used below takes a plain JSON body and is by far the easier one to write by hand. The GET form encodes the diagram source into the URL path using deflate plus URL-safe base64, which is what makes Kroki links embeddable straight into a Markdown image tag — useful, but you need a compression step to build the URL.

Quick facts

Base URL
https://kroki.io
Authentication
No API key and no signup for the public instance at kroki.io. Kroki is open source and self-hostable via Docker if you would rather not send diagram source to a third party.
Rate limit
No published hard limit on the public instance. Heavy or commercial use is expected to self-host.
Pricing
Free and open source (MIT). The hosted instance is community-run.
CORS
Enabled — callable directly from browser JavaScript
Official docs
Read the docs

How to use the Kroki API

Every request below was executed against the live API on 2026-08-21, and the response shown is the real body it returned — not an illustration.

1. Render a Graphviz diagram as SVG

POST https://kroki.io/

curl
curl -X POST 'https://kroki.io/' \
  -H 'Content-Type: application/json' \
  -d '{"diagram_source":"digraph G {Hello->World}","diagram_type":"graphviz","output_format":"svg"}'
JavaScript (fetch)
const res = await fetch("https://kroki.io/", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"diagram_source":"digraph G {Hello->World}","diagram_type":"graphviz","output_format":"svg"}),
});
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);
Python (requests)
import requests

headers = {
    "Content-Type": "application/json",
}

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

res = requests.post("https://kroki.io/", headers=headers, json=payload, timeout=20)
res.raise_for_status()
print(res.json())
Response — HTTP 200
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 14.1.3 (20260303.0454)
 -->
<!-- Title: G Pages: 1 -->
<svg width="89pt" height="116pt"
 viewBox="0.00 0.00 89.00 116.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="gr

Parameters

ParameterTypeRequiredDescription
diagram_sourcestringRequiredThe diagram source code, exactly as you would write it in a file. Sent in the JSON body. digraph G {Hello->World}
diagram_typestringRequiredWhich diagram language the source is written in. graphviz
output_formatstringOptionalOutput format. `svg` is supported by every diagram type; `png`, `pdf` and `jpeg` depend on the renderer. Defaults to SVG. svg
diagram_optionsobjectOptionalRenderer-specific options, for example a Mermaid theme.

Response fields

(body)image
The rendered diagram itself, returned as the raw response body rather than wrapped in JSON. Check `Content-Type` to know what you received.
Content-Typeheader
`image/svg+xml`, `image/png`, `application/pdf` or `image/jpeg`, matching the `output_format` you asked for.

What you can build with the Kroki API

  • Render architecture diagrams during a docs build without installing Graphviz or a JVM
  • Add live Mermaid or PlantUML previews to a wiki or CMS editor
  • Generate PNG diagrams for a PDF report pipeline
  • Embed a diagram in a GitHub README as a plain image URL

Common errors and how to fix them

400

The diagram source failed to parse, or `diagram_type` does not match the syntax you sent.

Fix: The response body carries the renderer's own error text — read it, it usually points at the offending line.

404

Unknown `diagram_type`, or an `output_format` that renderer does not support.

Fix: Check the supported matrix in the docs; not every diagram type can emit PNG or PDF.

413

Diagram source too large.

Fix: Split the diagram, or self-host with a raised limit.

Kroki API — frequently asked questions

Is the Kroki API free and does it need an API key?

Kroki is free and needs no API key or account. The hosted instance at kroki.io is community-run, and the whole project is MIT-licensed so you can run your own copy in Docker if you would rather not send diagram source off-site.

Which diagram languages does Kroki support?

Around 25, including Graphviz, Mermaid, PlantUML, D2, BPMN, C4, Ditaa, Excalidraw, Nomnoml, Structurizr, Vega, Vega-Lite and WaveDrom. Every one of them accepts the same POST body shape — only `diagram_type` changes.

What is the difference between the GET and POST forms?

POST takes the diagram source as plain text in a JSON body, which is easy to write by hand. GET encodes the source into the URL using deflate plus URL-safe base64, which produces a stable image URL you can drop straight into Markdown but requires a compression step to build.

Can I call Kroki from browser JavaScript?

Yes. It sends permissive CORS headers, so a fetch() from front-end code works. For SVG output you can insert the returned markup directly into the DOM.

Tools that pair with this API

Kroki is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-21; always check the official documentation before relying on this API in production, as terms and limits can change.