Skip to content

Instantly share code, notes, and snippets.

@philip-gai
Last active February 27, 2024 20:26
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save philip-gai/9c801bdff0ec4c1954f18217dc808476 to your computer and use it in GitHub Desktop.
Save philip-gai/9c801bdff0ec4c1954f18217dc808476 to your computer and use it in GitHub Desktop.
How to integrate diagrams.net (draw.io) with your GitHub repo

Embedding Diagrams in GitHub Markdown

This explains and demos how to use diagrams.net (draw.io) diagrams in your GitHub repo.

  • See repo for more details

Benefits of using diagrams.net in GitHub repositories

  1. Diagrams are stored in your repository with your code and docs
  2. Diagram access is controlled by GitHub repository access
  3. Diagrams are version-controlled using git
  4. Create PRs with diagram updates to get approvals and feedback
  5. One-click diagram editing from your GitHub repository
  6. diagrams.net is open-source: https://github.com/jgraph/drawio

How to integrate diagrams.net (draw.io) with your GitHub repo

Note: Images in markdown are cached and can take five minutes to update

Using VS Code locally, on github.dev or on CodeSpaces (Recommended)

This method does not require any OAuth or GitHub app approvals and defaults to offline mode. 🎉

Using the [Draw.io Visual Studio Code extension], you can do this in github.dev, Codespaces or locally on VS Code.

  1. Open the repository you want to create the diagram in
  2. Press . to open github.dev (or use Codespaces, or clone and use VS Code locally)
  3. Install the [Draw.io Visual Studio Code extension]
  4. Open or save a file ending with .drawio.svg or .drawio.png (svg is recommended). This will open the draw.io editor in VS Code.
  5. Reference the file using a relative link in markdown like you would reference any file ![Label](relative link)
  6. It will now live-update, you can use PRs to review changes, and you didn't need to authorize anything! 🚀

Reference: https://github.com/hediet/vscode-drawio#readme

Draw.io Extension Demo

@hericah
Copy link

hericah commented Sep 25, 2023

Thanks

@rishimithun-inivos
Copy link

This is awesome! Thanks for the guide!

@faheyr
Copy link

faheyr commented Feb 27, 2024

does this work on azure dev ops in terms of the git repo there and embedding within the ado wiki?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment