Troubleshooting — Common Errors and Fixes
Load this file when validation fails or diagrams don’t render correctly.Syntax Errors
1. Unexpected token / Parse error
Symptom:Parse error on line N: ...
Common causes and fixes:
| Cause | Bad | Good |
|---|---|---|
| Special chars in labels | A[User's Data] | A["User's Data"] |
| Unmatched brackets | A[Open label | A[Open label] |
| Missing arrow | A B | A --> B |
| Wrong arrow direction | A >>- B | A ->> B |
| Keyword as node ID | end --> start | endNode --> startNode |
| Curly braces in comment | %% {config} | %% config here |
2. Reserved Words as Node IDs
These words CANNOT be used as bare node IDs:end, graph, subgraph, flowchart, classDiagram, sequenceDiagram, stateDiagram, erDiagram, gantt, pie, click, style, class, linkStyle, default, direction
Fix: Append a suffix or use different names:
3. Quotes and Escaping
4. Empty Labels or Missing Content
Rendering Issues
5. Diagram Renders but Layout is Wrong
Symptom: Nodes overlap, arrows cross unnecessarily Fixes:- Change direction:
TD↔LR - Add invisible links for spacing:
A ~~~ B - Use subgraphs to group related nodes
- Reduce node count (split into multiple diagrams)
- Try
layout: elkin frontmatter (if supported)
6. Labels Cut Off or Truncated
Symptom: Long text gets clipped Fixes:7. Subgraph Won’t Render
Symptom: Subgraph shows as flat, no boundary Fixes:8. Theme Not Applied
Symptom: Diagram renders with default colors Causes:- beautiful-mermaid themes only work with that engine
- Frontmatter must be at the very start of the file
%%{init}directive must be on line 1- Some renderers ignore theme config
--theme flag. For beautiful-mermaid, use --theme parameter.
9. SVG Output is Blank or Tiny
Symptom: File is generated but empty or 0x0 pixels Causes:- Puppeteer/Chrome not installed (mmdc)
- File encoding issue (BOM marker)
- Syntax error that fails silently
10. mmdc Command Not Found
11. Puppeteer/Chrome Issues
Symptom:Error: Could not find Chrome
Diagram-Specific Issues
12. Sequence Diagram — Activation Mismatch
Symptom:Activation error or misaligned boxes
13. ERD — Relationship Syntax Error
14. C4 — Element Not Rendering
15. Gantt — Dates Not Parsing
16. Flowchart — Circular Reference Warning
Symptom: Infinite loop in rendering17. State Diagram — Composite State Errors
18. Architecture-beta — Not Rendering
Symptom: Raw text displayed instead of diagram Cause:architecture-beta requires Mermaid v11+
Fixes:
- Verify Mermaid version:
npx mmdc --version(needs 11+) - Use C4 or flowchart as fallback (see aws-architecture.md)
- Update mermaid-cli:
npm install -g @mermaid-js/mermaid-cli@latest
19. Architecture-beta — Icons Not Showing
Symptom: Icons show as generic boxes or are missing Cause:logos:aws-* icons require icon pack registration at render time
Fixes:
cloud, database, disk, server, internet
20. Architecture-beta — Massive Distances Between Arrows/Nodes
Symptom: Nodes are spaced extremely far apart, making arrows incredibly long and crossing other nodes messily. Cause: The architecture-beta renderer has no edge routing algorithms and places nodes in rigid, escalating grids. This breaks diagrams with > 8 nodes. Fix: DO NOT usearchitecture-beta for complex systems. Convert the diagram to a properly styled C4Container diagram immediately. C4’s layout engine spaces elements perfectly.
20. C4 — Lines Too Dark / Overlapping Elements
Symptom: Black lines create visual clutter, labels overlap with elements Cause: MissingUpdateRelStyle and UpdateLayoutConfig directives
Fixes:
21. General — Diagram Lines Too Dark/Harsh
Symptom: Diagram looks cluttered even with few nodes Cause: Default Mermaid theme uses black (#000000) lines Fix: Add init directive with soft line color:22. General — Init Directive Not Applying
Symptom: Colors don’t change despite adding%%{init} directive
Cause: The directive must be on the very first line (no blank lines before it)
Fix: Ensure %%{init} is the absolute first non-comment line:
Validation Script Errors
23. validate.mjs Reports False Positives
If the validator rejects valid syntax, it might be using an older Mermaid parser version. Try:24. Batch Script Hangs
Symptom: batch.mjs processes some files then stops Causes:- Too many workers for available memory
- One diagram has infinite loop syntax
- Puppeteer timeout on complex diagrams
Performance Tips
- Simple diagrams first — start with fewer nodes, add incrementally
- Split large diagrams — over 15 nodes hurts readability and rendering
- Use SVG over PNG — SVG renders faster and scales infinitely
- ASCII for CI/CD — no Puppeteer needed, fast and portable
- Batch in parallel — use
--workers 4for multiple files - Cache renders — only re-render when .mmd source changes
Rendering Quality Issues
25. Fonts Render as Times New Roman / Serif
Symptom: Text in the rendered PNG/SVG appears in an ugly serif font instead of the expected sans-serif font. Cause: The%%{init}%% directive uses fontFamily: 'system-ui' or fontFamily: 'Segoe UI' or other desktop-only fonts. These fonts are NOT available in headless Chromium (which mmdc uses internally), so the browser falls back to a serif font.
Fix: Do NOT set fontFamily at all (Mermaid’s default trebuchet ms, verdana, arial, sans-serif works perfectly), or use only universally available fonts:
26. Theme / Init Directive Ignored When Rendering
Symptom: You set%%{init: {'theme': 'dark', ...}}%% in your .mmd file but the diagram renders with the default light theme.
Cause: The render script passes a config file with {"theme": "default"} via mmdc -c, which was overriding the init directive in the diagram.
Fix: This bug has been fixed in the render script — it now detects %%{init in the input file and does NOT pass a theme in the config file, allowing the init directive to take full precedence. If you still experience this issue, verify:
- The
%%{init}%%directive is on the very first line of the.mmdfile (no blank lines before it) - You are NOT passing
--themeto the render script when using init directives - The render script version includes the
hasInitDirectivedetection fix
27. Render Script Fails Silently with mmdc=no
Symptom: The render script reports Engines: mmdc=no even though mmdc is installed in .deps/node_modules/.bin/.
Cause: The skill’s directory path contains special characters (like parentheses in (tooling)) that break shell execution in execSync(). The shell interprets ( as subshell syntax and fails.
Fix: This bug has been fixed in the render script — all paths are now wrapped with shellQuote() which uses single quotes to protect against special characters. If you still experience this issue, verify that the shellQuote() function exists in render.mjs and is used for all path arguments in execSync() calls.