Skip to content
Kong Docs are moving soon! Our docs are migrating to a new home. You'll be automatically redirected to the new site in the future. In the meantime, view this page on the new site!
Kong Logo | Kong Docs Logo
  • Docs
    • Explore the API Specs
      View all API Specs View all API Specs View all API Specs arrow image
    • Documentation
      API Specs
      Kong Gateway
      Lightweight, fast, and flexible cloud-native API gateway
      Kong Konnect
      Single platform for SaaS end-to-end connectivity
      Kong AI Gateway
      Multi-LLM AI Gateway for GenAI infrastructure
      Kong Mesh
      Enterprise service mesh based on Kuma and Envoy
      decK
      Helps manage Kong’s configuration in a declarative fashion
      Kong Ingress Controller
      Works inside a Kubernetes cluster and configures Kong to proxy traffic
      Kong Gateway Operator
      Manage your Kong deployments on Kubernetes using YAML Manifests
      Insomnia
      Collaborative API development platform
  • Plugin Hub
    • Explore the Plugin Hub
      View all plugins View all plugins View all plugins arrow image
    • Functionality View all View all arrow image
      View all plugins
      AI's icon
      AI
      Govern, secure, and control AI traffic with multi-LLM AI Gateway plugins
      Authentication's icon
      Authentication
      Protect your services with an authentication layer
      Security's icon
      Security
      Protect your services with additional security layer
      Traffic Control's icon
      Traffic Control
      Manage, throttle and restrict inbound and outbound API traffic
      Serverless's icon
      Serverless
      Invoke serverless functions in combination with other plugins
      Analytics & Monitoring's icon
      Analytics & Monitoring
      Visualize, inspect and monitor APIs and microservices traffic
      Transformations's icon
      Transformations
      Transform request and responses on the fly on Kong
      Logging's icon
      Logging
      Log request and response data using the best transport for your infrastructure
  • Support
  • Community
  • Kong Academy
Get a Demo Start Free Trial
Contribution guidelines
  • Home icon
  • Style guide and contribution guidelines
  • Diagrams in the docs
github-edit-pageEdit this page
report-issueReport an issue
  • Kong Gateway
  • Kong Konnect
  • Kong Mesh
  • Kong AI Gateway
  • Plugin Hub
  • decK
  • Kong Ingress Controller
  • Kong Gateway Operator
  • Insomnia
  • Kuma

  • Docs contribution guidelines
  • Contribution guidelines
  • Style guidelines
    • Style guide
    • Word choice and naming
    • Notes and other notices
    • Diagrams
    • Documenting user interfaces
    • Contribution templates
    • Plugin documentation
      • Documenting Kong-owned plugins
      • Documenting partner plugins
  • Markdown rules and formatting
    • Markdown rules
    • Reusable content
    • Variables
    • Single-sourced versions
    • Single-sourced plugins
    • Conditional rendering
  • Community
    • Welcome to the Kong Docs community
    • Community expectations
    • Hackathons
enterprise-switcher-icon Switch to OSS
On this pageOn this page
  • Add a diagram to the docs
  • Styling
  • Export a Mermaid diagram from the docs

Diagrams in the docs

The Kong Docs include built-in support for mermaid.js. This tool lets you build diagrams directly in Markdown without needing any extra diagram software.

We recommend using Mermaid’s online editor to write your diagrams and see the output side-by-side. When you’re happy with it, copy the code and paste it directly into a docs markdown file.

Tip: If you want to see what the diagram will look like in the docs, use this sample chart with styling config instead, and switch the Theme in the top menu to light mode.

The most commonly used diagram types in the Kong docs are the flowchart and the sequence diagram. You can cover most use cases with these two types. Follow mermaid.js’s docs to learn about node and link styles for each diagram.

If you run into node or link positioning issues in flowcharts, try to rearrange the elements in the chart, link them in different ways, or change the direction of the chart. You can also use subgraphs to help with positioning.

Add a diagram to the docs

To add a diagram to a doc, declare it with the {% mermaid %} and {% endmermaid %} tags.

Here’s an example of a flowchart with links to the final decisions:

{% mermaid %}
flowchart TD
    %% this section defines the node and their labels
    A{Deployment type?}
    B(Traditional mode)
    C(Hybrid mode)
    D(DB-less mode)
    E(Konnect DP)
    F{Enough hardware to 
    run another cluster?}
    G(Upgrade CP first)
    H(Upgrade DP second)
    I([Dual-cluster upgrade])
    J([In-place upgrade])
    K([Rolling upgrade])

    %% this section defines all the connections between nodes
    A --> B
    A --> C
    A --> D
    A --> E
    B ---> F
    C --> G & H
    D ----> K
    E ----> K
    G --> F
    F ---Yes--->I
    F ---No--->J
    H ---> K

    %% this section defines node interactions
    click K "/gateway/latest/upgrade/rolling-upgrade/"
    click I "/gateway/latest/upgrade/dual-cluster/"
    click J "/gateway/latest/upgrade/in-place/"
{% endmermaid %}

The code above creates the following diagram:

 
flowchart TD
    %% this section defines the nodes
    A{Deployment type?}
    B(Traditional mode)
    C(Hybrid mode)
    D(DB-less mode)
    E(Konnect DP)
    F{Enough hardware to 
    run another cluster?}
    G(Upgrade CP first)
    H(Upgrade DP second)
    I([Dual-cluster upgrade])
    J([In-place upgrade])
    K([Rolling upgrade])

    %% this section defines all the connections between nodes
    A --> B
    A --> C
    A --> D
    A --> E
    B ---> F
    C --> G & H
    D ----> K
    E ----> K
    G --> F
    F ---Yes--->I
    F ---No--->J
    H ---> K

    %% this section defines node interactions
    click K "/gateway/latest/upgrade/rolling-upgrade/"
    click I "/gateway/latest/upgrade/dual-cluster/"
    click J "/gateway/latest/upgrade/in-place/"
  

Styling

All diagrams built with mermaid.js have built-in styling. If you need to adjust styling, you can set styles in the diagram definition with the style tag for nodes, or the linkStyle tag for lines.

Tip: Since links (aka lines or connectors) don’t have names/IDs like nodes do, you have to style links by numbering them. It can be difficult to tell what order the links are in, and which connector the style will apply to. Mermaid’s online editor lets you test this out in real time, so you can quickly figure out the numbers.

To avoid having to reshuffle anything or re-figure out the numbers, apply link styling after you have added all the nodes and links to your diagram.

Here are some basic style tags to know:

  • fill: The background color of an element
  • stroke: The line color of an element. For a node, this refers to a border color; for a link, this refers to its line color.
  • stroke-dasharray: Turns the border of a node into a dashed line.

    Note that you don’t need to do this for links, as you can specify a dotted link by using -.-> instead of -->.

Here’s some examples of these styles in use:

style API stroke:none
# Removes the border from the API node

style DBX stroke-dasharray:3
# Turns the border of the DBX node into a dashed line

style Admin fill:none,stroke:none,color:#d44324
# Removes the fill and border of the admin node and changes the text colour to the hex code above

linkStyle 4,7 stroke:#d44324,color:#d44324
# Changes the line and text color of the 4th and 7th connectors in the diagram

linkStyle 3,6,9 stroke:#b6d7a8
# Changes the line color of the 3rd, 6th, and 9th connectors in the diagram

These styles are all used to create the following diagram:

Diagram
Source code of diagram
 
flowchart TD
    DBX[(Current
    database)]
    DBY[(New 
    database)]
    CPX(Current 
    Kong Gateway X)
    Admin(No admin 
    write operations)
    Admin2(No admin 
    write operations)
    CPY(New 
    Kong Gateway Y)
    LB(Load balancer)
    API(API requests)

    API --> LB & LB & LB & LB
    Admin2 -."X".- CPX
    LB -.90%.-> CPX
    LB --10%--> CPY
    Admin -."X".- CPY
    CPX -.-> DBX
    CPY --pg_restore--> DBY

    style API stroke:none
    style DBX stroke-dasharray:3
    style CPX stroke-dasharray:3
    style Admin fill:none,stroke:none,color:#d44324
    style Admin2 fill:none,stroke:none,color:#d44324
    linkStyle 4,7 stroke:#d44324,color:#d44324
    linkStyle 3,6,9 stroke:#b6d7a8
  
{% mermaid %}
flowchart TD
    DBX[(Current
    database)]
    DBY[(New 
    database)]
    CPX(Current 
    {{site.base_gateway}} X)
    Admin(No admin 
    write operations)
    Admin2(No admin 
    write operations)
    CPY(New 
    {{site.base_gateway}} Y)
    LB(Load balancer)
    API(API requests)

    API --> LB & LB & LB & LB
    Admin2 -."X".- CPX
    LB -.90%.-> CPX
    LB --10%--> CPY
    Admin -."X".- CPY
    CPX -.-> DBX
    CPY --pg_restore--> DBY

    style API stroke:none
    style DBX stroke-dasharray:3
    style CPX stroke-dasharray:3
    style Admin fill:none,stroke:none,color:#d44324
    style Admin2 fill:none,stroke:none,color:#d44324
    linkStyle 4,7 stroke:#d44324,color:#d44324
    linkStyle 3,6,9 stroke:#b6d7a8
{% endmermaid %}

Export a Mermaid diagram from the docs

You can export a Mermaid diagram from the Kong docs using the Mermaid live editor. This method will only work with diagrams that don’t contain icons or images.

  1. Copy the Mermaid diagram from the Kong doc file. You can find the doc source file by clicking Edit this page at the top right corner of the doc.
  2. Paste the Mermaid diagram into the Mermaid live editor.
  3. If the diagram contains images, remove all <img> tags.
  4. Replace any Liquid variables (for example, {{site.base_gateway}}) with their output. Liquid variables won’t render correctly in the Mermaid live editor.
  5. Click Actions on the bottom left corner and select the file type you want to export the diagram to.
Thank you for your feedback.
Was this page useful?
Too much on your plate? close cta icon
More features, less infrastructure with Kong Konnect. 1M requests per month for free.
Try it for Free
  • Kong
    Powering the API world

    Increase developer productivity, security, and performance at scale with the unified platform for API management, service mesh, and ingress controller.

    • Products
      • Kong Konnect
      • Kong Gateway Enterprise
      • Kong Gateway
      • Kong Mesh
      • Kong Ingress Controller
      • Kong Insomnia
      • Product Updates
      • Get Started
    • Documentation
      • Kong Konnect Docs
      • Kong Gateway Docs
      • Kong Mesh Docs
      • Kong Insomnia Docs
      • Kong Konnect Plugin Hub
    • Open Source
      • Kong Gateway
      • Kuma
      • Insomnia
      • Kong Community
    • Company
      • About Kong
      • Customers
      • Careers
      • Press
      • Events
      • Contact
  • Terms• Privacy• Trust and Compliance
© Kong Inc. 2025