Formatting
Mermaid Studio can automatically format your diagram code to improve readability and maintain consistent style.
Format Your Code
Section titled “Format Your Code”To format the current file:
- Windows/Linux: Press
Ctrl+Alt+L - macOS: Press
Cmd+Option+L
You can also access formatting through:
- Code menu -> Reformat Code
- Right-click in the editor -> Reformat Code
What Formatting Does
Section titled “What Formatting Does”The formatter cleans up your diagram code by:
- Fixing indentation levels
- Normalizing spacing around arrows and operators
- Aligning related elements
- Removing excessive blank lines
Format on Save
Section titled “Format on Save”To automatically format diagrams when you save:
- Open Settings -> Tools -> Actions on Save
- Enable Reformat code
- Mermaid files will be formatted each time you save
Supported Diagram Types
Section titled “Supported Diagram Types”Formatting support varies by diagram type:
- Flowcharts - Full support
- ER Diagrams - Full support
- Class Diagrams - Full support
- Gantt Charts - Full support
- Sequence Diagrams - Partial support
- State Diagrams - Full support
Diagram types without dedicated formatting still benefit from basic indentation cleanup.
Format Selection Only
Section titled “Format Selection Only”To format just part of your diagram:
- Select the lines you want to format
- Press
Ctrl+Alt+L(Windows/Linux) orCmd+Option+L(macOS)
Only the selected code will be reformatted.