Skip to content
Lower pricing Individual licenses are now $49/year for Studio, $25 for Core — See pricing →

TreeView Diagram

Last updated:

Mermaid Studio provides language support for TreeView diagrams inside IntelliJ IDEA and other JetBrains IDEs. TreeView diagrams display hierarchical data as an indented tree, similar to a file browser: each line is a node, and indentation alone determines parent-child relationships. TreeView is a beta diagram type and requires Mermaid.js 11.14.0 or later.

Syntax highlighting integrates directly with IntelliJ’s color scheme system, so diagram colors always match your editor theme.

TreeView syntax highlighting in Armada Dark theme

The summary below shows the IDE support Mermaid Studio ships for TreeView diagrams, grouped by capability.

IDE feature supportSelect a feature for its description.
Editing
Code Intelligence
Validation
Appearance
treeView-beta
title Project Structure
"root"
"src"
"main"
"index.ts"
"app.ts"
"utils.ts"
"test"
"app.test.ts"
"utils.test.ts"
"docs"
"README.md"
"CONTRIBUTING.md"
"package.json"
"tsconfig.json"

Key elements:

  • Start with treeView-beta
  • Optionally include title, accTitle, and accDescr metadata before any node rows
  • Node names may be quoted (double or single quotes) or, on Mermaid.js 11.16.0+, bare (index.ts)
  • Indentation determines hierarchy - nested nodes are children of the less-indented node above
  • On Mermaid.js 11.16.0+, box-drawing guides (├──, , └──) such as the output of tree are accepted in place of plain indentation; see Editing for how the editor maintains either form
  • On Mermaid.js 11.16.0+, a node name may be followed by annotations: :::class applies a CSS class, icon(...) attaches an icon (see Icons), and ## text adds a description

The editor keeps the tree’s structure intact as you type, whether it uses plain indentation or box-drawing guides. Press Enter and the new row starts with the indent or connector for its level, one level deeper when the row above names a directory (a name ending in /). In a box-drawing tree, Tab makes the row a child of the row above, and Shift+Tab or Backspace at the start of the row moves it back out; either way the neighboring ├──, └──, and guides are redrawn to match. The loop below shows a tree growing this way, with rows moved between levels by keyboard alone:

If you’d prefer the platform’s own Tab, Shift+Tab, and Backspace behavior, turn the three keys off under Settings > Editor > General > Smart Keys > Mermaid Studio.

Reformat Code re-indents every row by its place in the tree, repairs connectors that no longer match the structure, and converts between the two notations. The Indentation form option (Keep existing, Whitespace, or Box-drawing characters) on Settings > Editor > Code Style > Mermaid > TreeView chooses the notation it writes, and the same page sets the base indent level for the whitespace form.

Settings dialog on Editor, Code Style, Mermaid, TreeView with the Wrapping and Braces tab selected, showing the Tree structure group with the Indentation form option set to Keep existing and a sample tree on the right

On Mermaid.js 11.16.0+, an icon() annotation after a node name attaches an icon to the node. The built-in folder and file icons are referenced by bare name, and any icon from an enabled icon set is referenced as pack:name. The example below mixes both forms:

treeView-beta
"project"
"src" icon(folder)
"index.ts" icon(logos:typescript-icon) ## entry point
"README.md" icon(file)

An unprefixed name that is not a built-in resolves through the config.treeView.defaultIconPack frontmatter key, so with defaultIconPack: logos you can write icon(typescript-icon). Writing icon(none) or an empty icon() suppresses the icon. The defaultIconPack, filenameIcons, and extensionIcons config keys get completion and validation in the frontmatter block; see the Mermaid.js TreeView documentation for what each key does.

Completion inside the parentheses offers the built-ins and every icon from your enabled icon sets, each with a preview, shown here filtered to the logos pack:

TreeView diagram in the editor with the completion popup open inside icon(logos:), listing logos-pack icons with image previews

Typing a pack prefix such as logos: filters the list to that pack, and the popup opens automatically when you type ( or :. When a defaultIconPack is set, that pack’s icons also complete as bare names. A reference that resolves to no built-in, default-pack, or enabled icon-set icon is flagged with a weak warning, since it would render no icon.

Which icon sets are enabled, and how to add your own, is covered in Icon Sets.

For complete syntax details, see the Mermaid.js TreeView documentation.