Create Diagrams In VS Code With Draw.io

hediet

Henning Dieterichs

Posted on October 6, 2020

Create Diagrams In VS Code With Draw.io

Diagrams are a great way to communicate ideas visually and can be used to extend or sometimes even replace textual documentations of software projects. This article describes how you can create diagrams without ever leaving VS Code.

Use Cases

Here are some use cases for diagrams. Maybe they inspire you to use diagrams more often!

  • Documentation of how large scale components depend on each other: Documentation of how large scale components
  • Highlighting relationships between classes: Class Diagram
  • Wireframes: Wireframe
  • Page Transitions using Screenshots: Page Transition Diagram

You can use diagrams for much more!

All those diagrams have been created with Draw.io in VS Code.

Create Diagrams in VS Code

To create such diagrams in VS Code without ever leaving your editor, you just need to install the Draw.io Integration extension from the Marketplace:

Installation

After installation, you can simply create a *.drawio file in the explorer view:

Create Diagrams

From there you get the typical Draw.io interface where you can draw your diagrams:

Edit Diagrams

You can even use git to track changes of your Draw.io files!

Themes

Draw.io offers multiple themes that you can use in VS Code:

Themes Demo

Create Editable SVG Diagrams

You can either directly create a *.drawio.svg file instead of *.drawio or convert any existing diagram to an SVG file. Such SVG files are still editable Draw.io diagrams! You can embed such diagrams in Markdown files and even view them on github. Conversion to PNG is also possible!

SVG/PNG Conversion

Code Links

With code links, you can associate code with your nodes or edges by just naming the node like the name of a class or function and prepending the name with #. So if you class is MyClass, the node should be called #MyClass. You also need to activate code links in the status bar. When you double click on a node with such a name, you jump to the class!

Code Links Demo

Collaborative Editing

With Liveshare, you can even edit diagrams collaboratively!

Collaborative Editing Demo

Much More

Draw.io has much more to offer. You can use LaTeX for formulas, add free-hand drawings or paste screenshots from your clipboard right into the diagram!
All these features are also available for Draw.io in VS Code!

💖 💪 🙅 🚩
hediet
Henning Dieterichs

Posted on October 6, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related