Mermaid CLI icon

Mermaid CLI

Execute Mermaid CLI commands for diagram generation

Generate Diagram

AI-generated

Overview

This node operation generates diagrams from Mermaid syntax using the Mermaid CLI. It supports input either as Mermaid text code or from a file path. Users can specify the output format (SVG, PNG, PDF) and output type (file content as text/base64, binary data, or file path). The node allows customization of the diagram's theme, background color, and dimensions (width and height for PNG). It is useful for automating the creation of visual diagrams in workflows, such as flowcharts, sequence diagrams, or other Mermaid-supported diagrams.

Use Case Examples

  1. Generating a flowchart diagram from Mermaid text and returning it as a PNG image in binary format for further processing in a workflow.
  2. Reading Mermaid code from a file, generating an SVG diagram, and saving the output to a specified file path.
  3. Customizing the diagram's theme and background color to match branding requirements before exporting as a PDF.

Properties

Name Meaning
Input Source Select whether the Mermaid diagram code is provided as text or read from a file path.
Mermaid Code The Mermaid diagram code to render, used when input source is text.
Input File Path Path to the input Mermaid file, used when input source is file.
Output Format The format of the generated diagram output.
Output Type How the output diagram is returned or saved.
Output Path File path to save the output diagram, required if output type is 'File Path Only'.
Binary Property Name Name of the binary property to store the diagram data when output type is binary.
File Name File name for the binary data; auto-generated if empty.
Theme Theme style for the diagram.
Background Color Background color for the diagram.
Width Width of the output image in pixels, applicable for PNG format.
Height Height of the output image in pixels, applicable for PNG format.

Output

Binary

Binary output contains the generated diagram data encoded in base64, with MIME type and file metadata, suitable for use in workflows.

JSON

  • success - Indicates if the diagram generation was successful.
  • inputPath - Path to the input Mermaid file or temporary file created from text input.
  • outputPath - Path where the generated diagram file is saved.
  • format - Output format of the diagram (svg, png, pdf).
  • outputType - Type of output returned (fileContent, binary, filePath).
  • options
    • theme - Theme used for the diagram.
    • backgroundColor - Background color used for the diagram.
    • width - Width of the output image in pixels (for PNG).
    • height - Height of the output image in pixels (for PNG).
  • content - Diagram content as text or base64 encoded string when output type is fileContent.
  • contentType - MIME type of the content when output type is fileContent.
  • binary - Binary data object containing the diagram data when output type is binary.

Dependencies

  • Mermaid CLI executable (mmdc) must be installed and accessible in the environment.
  • Node requires access to file system for reading input files and writing output files.
  • Uses Puppeteer Chromium browser for rendering diagrams.

Troubleshooting

  • Ensure the Mermaid CLI (mmdc) is installed and the executable path is correctly set in the environment variables.
  • If using 'File Path Only' output type, the output path must be specified and writable.
  • Errors related to diagram rendering may occur if the Mermaid syntax is invalid or unsupported; validate syntax before generating.
  • Temporary files are created during processing; ensure the environment's temp directory is accessible and has sufficient space.
  • If binary output is selected, ensure the binary property name is unique and does not conflict with existing data in the workflow.

Links

Discussion