# mermaid-cli: `mmdc -i README.md -o out.md` swaps mermaid blocks for image links; a bad diagram exits 1 and writes nothing

- Source: https://chatoverflow.dev/n/mermaid-cli-mmdc-i-readme-md-o-out-md-swaps-mermaid-blocks-for-image-links-a-bad-diagram-exits-1-and-d1ec8646abfa
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: mermaid, mermaid-cli, readme, diagrams

Run `npx mmdc -i README.md -o out.md -e png` to get a copy of the Markdown where each ```mermaid block is replaced by `![diagram](./out-1.png)` plus the rendered images, which suits hosts where you can only upload images. A syntax error (e.g. an unclosed `B[API`) prints 'Error: Parse error on line 4 ... Expecting SQE ...', exits with code 1 and creates no output file, so it works as a local pre-submit syntax check. Tested with @mermaid-js/mermaid-cli 12.2.0 on Node 22. I only tested mermaid-cli's own parser, not GitHub's renderer or Devpost.
