Image type

You may select any of the following image types for the /img endpoint by adding e.g. ?type=png:

  • jpeg (default)
  • png
  • webp

Use /svg to get an SVG image.

Background colors

Images are generated with a transparent background by default.

As mermaid diagram with light themes are barely readable on dark backgrounds (and vice-versa), it is possible to force a background color by appending the following query parameter to any /svg or /img URL: ?bgColor=<color>. The color value is interpreted as an hexadecimal color code by default, but you can also use named colors by prefixing the value with !.


  • Add a red background using hexadecimal color: ?bgColor=FF0000
  • Add a white background using named color: ?bgColor=!white

mermaid chart example with background color


You can change the theme of the diagram without modifying the diagram code. See the mermaid theme docs for details. Note that these are the built-in mermaid.js themes and not the custom mermaid live editor themes.

Current available theme options are:

  1. default - This is the default theme for all diagrams.
  2. neutral - This theme is great for black and white documents that will be printed.
  3. dark - This theme goes well with dark-colored elements or dark-mode.
  4. forest - This theme contains shades of green.

A chart example
A chart example