Skip to content

Command line tool for the Mermaid library

License

Notifications You must be signed in to change notification settings

bentitopolis/mermaid-cli

 
 

Repository files navigation

mermaid-cli

This is a command-line interface (CLI) for mermaid. It takes a mermaid definition file as input and generates an svg/png/pdf file as output.

Join our Slack! This project is using Percy.io for visual regression testing. Build, test and deploy

Use Docker:

docker pull minlag/mermaid-cli

or e.g. version 8.8.0

docker pull minlag/mermaid-cli:8.8.0

Install locally

Some people are having issue installing this tool globally. Installing it locally is an alternative solution:

yarn add @mermaid-js/mermaid-cli
./node_modules/.bin/mmdc -h

Or use NPM:

npm install @mermaid-js/mermaid-cli
./node_modules/.bin/mmdc -h

Install globally

❗️ We do NOT recommend installing it globally because both YARN and NPM could fail to install a command-line tool globally properly due to weird permission issues. yarn global add @mermaid-js/mermaid-cli or npm install -g @mermaid-js/mermaid-cli

Examples

To see the latest options, please run the following command: mmdc -h

To convert Mermaid mmd diagram to an svg file, run this command: mmdc -i input.mmd -o output.svg

Piping from stdin

You can also pipe input from stdin

# create_mermaid_output is an executable that sends mermaid output to stdout
create_mermaid_output | mmdc -o output.svg
cat << EOF | mmdc
sequenceDiagram
    participant Alice
    participant Bob
    Alice->>John: Hello John, how are you?
    loop Healthcheck
        John->>John: Fight against hypochondria
    end
    Note right of John: Rational thoughts <br/>prevail!
    John-->>Alice: Great!
    John->>Bob: How about you?
    Bob-->>John: Jolly good!
EOF

Run with npx

npx is installed by default with NPM. It downloads and runs commands at the same time. To use Mermaid CLI with npx, you need to use the -p flag because the package name is different than the command it installs (mmdc). npx -p @mermaid-js/mermaid-cli mmdc -h

Known issues

  1. Linux sandbox issue

For contributors

Contributions are welcome. See the contribution guide.

About

Command line tool for the Mermaid library

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 80.5%
  • Shell 6.8%
  • Dockerfile 5.9%
  • CSS 3.4%
  • HTML 3.4%