Syntax

You can declare positional and named attributes when using the block or macro form.

Positional attributes

Block form

  1. The first positional attribute specifies the diagram type.

  2. The second optional positional attribute assigns a file name (i.e., target) to the generated diagram.

  3. The third optional positional attribute specifies the image format.

[mermaid,abcd-flowchart,svg]
----
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
----

In the above example, the diagram type is mermaid, the target is abcd-flowchart, and the image format is svg.

Macro form

  1. The first optional positional attribute specifies the image format.

vegalite::chart.vlite[svg]

In the above example, the diagram type is vegalite, the target is chart.vlite, and the image format is svg.

Named attributes

You can combine positional and named attributes:

.PlantUML example
[plantuml#diagAliceBob,alice-and-bob,svg,role=sequence]
----
alice -> bob
----

In this example, an id is assigned using #diagAliceBob after the diagram type, and a role is defined using role=sequence.

With the macro form:

vegalite::chart.vlite[svg,role=chart,opts=interactive]

A positional attribute declares the image format, and two named attributes define the role and opts.

Attributes

The following attributes are used by the built-in HTML 5 converter:

Attribute Description

target

File name for the generated image

width

Image width

height

Image height

format

Image format (default: svg)

fallback

Fallback image if the diagram cannot be rendered

link

URL to link the image to

float

Image float (left or right)

align

Image alignment

role

CSS class(es) to apply to the image, in addition to the kroki and kroki-format-<format> classes that are always added

title

Block title, displayed as the figure caption

caption

Caption prefix displayed before the block title, replacing the automatic Figure N. label

The image alt text is derived from title when set, then from target, and falls back to Diagram.

Options

The following options are available when using the SVG format:

Option Description

inline

Inline the SVG content directly in the HTML

interactive

Make the SVG interactive (e.g., for Vega-Lite)

none

Cancel any default options

Options are defined using the options attribute (or opts for short):

[blockdiag,opts=inline]
----
blockdiag {
  Kroki -> generates -> "Block diagrams";

  Kroki [color = "greenyellow"];
  "Block diagrams" [color = "pink"];
}
----

To inline an SVG, the converter must be able to read its content. When the allow-uri-read attribute is set, the converter fetches the content from the Kroki server URL. Otherwise, the extension embeds the diagram as a data-URI (requires safe mode server or lower).

Substitutions

Use the subs attribute to apply AsciiDoc substitutions to the diagram source before it is sent to the Kroki server. For example, subs=attributes substitutes document attributes:

:node-color: greenyellow

[blockdiag,subs=attributes]
----
blockdiag {
  Kroki -> generates -> "Block diagrams";

  Kroki [color = "{node-color}"];
}
----
Do not include the specialcharacters substitution: it replaces <, >, and & with HTML entities, which would make the diagram source invalid.

Diagram-specific options

Any named attribute that is not a built-in attribute is forwarded to the Kroki server as a diagram-specific option (query parameter). This allows you to pass diagram type options supported by Kroki directly on the block or macro.

Consult the Kroki documentation for the available options per diagram type.

For example, Structurizr workspaces often define multiple views. By default, only the last view is rendered. Use the view-key option to specify which view to render:

[structurizr,view-key=SystemContext]
----
workspace {
  model {
    user = person "User"
    system = softwareSystem "Software System"
    user -> system "Uses"
  }
  views {
    systemContext system "SystemContext" {
      include *
    }
  }
}
----

Supported diagram types

Kroki currently supports the following diagram libraries:

Library Block/macro name

ActDiag

actdiag

BlockDiag

blockdiag

BPMN

bpmn

Bytefield

bytefield

C4 (PlantUML)

c4plantuml

D2

d2

DBML

dbml

Ditaa

ditaa

ERD

erd

Excalidraw

excalidraw

GoAT

goat

GraphViz

graphviz

Mermaid

mermaid

Nomnoml

nomnoml

NwDiag

nwdiag

PacketDiag

packetdiag

Pikchr

pikchr

PlantUML

plantuml

RackDiag

rackdiag

SeqDiag

seqdiag

SVGBob

svgbob

Symbolator

symbolator

TikZ

tikz

UMLet

umlet

Vega

vega

Vega-Lite

vegalite

WaveDrom

wavedrom

WireViz

wireviz

Structurizr

structurizr

Diagrams.net [1]

diagramsnet

Output formats

Each diagram library supports one or more output formats: svg, png, jpeg, pdf, base64, and the text formats txt, atxt, and utxt. Consult the Kroki documentation for the supported formats per library.

When a text format is requested, the diagram is rendered as a literal block containing its textual representation (e.g., ASCII art for a PlantUML sequence diagram) instead of an image:

[plantuml,format=txt]
----
alice -> bob
----

1. Only available via self-hosted Kroki.