Today I Learned

Fixing Database Mermaid Diagrams Generated by IntelliJ

If you’re using IntelliJ to visualize your database schema with a Mermaid diagram and encountering a rendering error in the Mermaid live editor, here’s a quick fix.

While exporting your database schema to a Mermaid diagram via IntelliJ’s ‘Export to File’ > ‘Mermaid.md’ function, you might end up with a parse error: Error: Parse error ... Expecting 'NEWLINE', 'EOF', got 'LABEL'. This happens due to the colon (:) in the table column identifiers that Mermaid can’t parse.

Solution: Simply replace all colons (:) with the HTML entity &#58 in your ‘Mermaid.md’ content.

Here are the steps:

  1. Open your IntelliJ-generated ‘Mermaid.md’ file.
  2. Use find-and-replace to substitute colons (:) with &#58.
  3. Paste the modified content into the Mermaid live editor.

Your diagram should now display correctly, showing your database schema without any errors. This straightforward solution bypasses the Mermaid parser issue and lets you visualize your schema in no time.