Skip to main content

open-diagram

Python building blocks for dense architecture diagrams that check their own layout.

Website, gallery and docs: open-diagram.dev · How it compares with Mermaid, D2, draw.io, Excalidraw and archify: docs/comparison.md

A systems map for an invented video platform, drawn with open-diagram

You describe panels, tiles, lines and groups in a short Python script. open-diagram measures every label from the font, places the blocks, and checks the result. If two panels collide or a line runs through a panel, the build says so by name. The output is an SVG (a picture made of shapes, sharp at any size) and a PNG.

The same blocks draw software systems, release pipelines, layered stacks, data models and business processes. It is built to be written by an AI agent such as Claude, Codex or Cursor, as well as by people. The checks catch layout mistakes before anyone looks at the picture, so a first attempt usually comes out clean.

Install

pip install open-diagram

For the newest unreleased code: pip install git+https://github.com/lukendeasy/open-diagram.

open-diagram needs Python 3.9 or later and fontTools, which pip installs for you. To make PNG files it also needs Google Chrome, Chromium or Microsoft Edge. If yours is not in the usual place, set the CHROME environment variable to its path. The SVG is always written, browser or not.

For AI apps that use MCP, such as Claude Code: claude mcp add open-diagram -- uvx --python 3.12 --from "open-diagram[mcp]" open-diagram-mcp. Claude Desktop, Cursor and the agent skill are in AI agents.

Quick start

from open_diagram import Diagram, Panel, Tile

d = Diagram("How a search request is answered", tag="EXAMPLE")
app = d.add(Panel("Web app", ["Search box", "Results page", "Filters"], footer="Owner: Web team"))
api = d.right_of(app, Panel("Search API", [Tile("Checks access"), Tile("Caches results", status="building")],
                            footer="Owner: Platform team"), align="center")
index = d.right_of(api, Panel("Search index", ["Product text", Tile("Spelling fixes", status="planned")],
                              status="planned"), align="center")
d.link(app, api)
d.link(api, index, kind="planned", label="new")
d.save("quickstart")   # writes quickstart.svg and quickstart.png

The quick start diagram

The key at the top lists only the statuses and line kinds the picture uses.

Why a first attempt comes out clean

  • Every label is measured before it is placed. Widths come from the font's own spacing and kerning, so each box fits its words.
  • The build checks the layout and names each problem. For example: 'Storage' and 'Recommendations' are only 9 px apart (minimum 16) or line 'Where videos come from' -> 'Storage' crosses 'Processing'; route it with via_x/via_y, move a block, or pass cross_ok=True. save() writes the files, prints a summary, then raises LayoutError with the full list.
  • Text is drawn as shapes. The SVG looks the same in a browser, PowerPoint, Keynote or Figma, with or without the font installed. Inter comes bundled.
  • Words stay apart from layout. Keep labels in lists at the top of the script. Changing a word does not move anything by hand.

How open-diagram turns a script into a picture, drawn with open-diagram

Examples

Each example is one script in examples/. Run any of them with python3 examples/<name>.py.

Example Shows
systems_map.py A video platform from upload to screen: columns, a group, steps, statuses, owners, a small data map with a worked example, and lanes above and below the picture
how_it_works.py How open-diagram itself works, drawn with open-diagram
pipeline.py A release pipeline from pull request to production, with a rollback lane
card_payment.py What happens when you tap a card: numbered steps for the order of events, return paths above and below
layers.py A web product as stacked layers, with a side panel
concept_map.py How git stores a project: its objects and links, with a worked example
smart_home.py A smart home from sensor to phone, with a planned overnight update path
incident_response.py How a team handles an outage, from the first alert to the lessons learned
business_map.py Not only software: a furniture store from order to doorstep
email_delivery.json How an email is delivered, written as JSON instead of Python
signup_flow.mmd A sign-up flow imported from a Mermaid flowchart
release_cycle.json A release cycle as a ring, with goals in the middle
quickstart.py The code above

All of them, and the cloud templates, are in the gallery.

Docs

The full reference is at open-diagram.dev/docs.html, drawn from these files:

Topic File
Python: every block, placement method and theme setting docs/python.md
JSON: every key docs/json.md
Mermaid: what it reads and what changes docs/mermaid.md
Command line and the GitHub Action docs/cli.md
AI agents: the MCP server, the agent skill and cloud icons docs/agents.md
Cloud templates and the template standard templates/README.md
What each layout problem means and how to fix it skills/open-diagram/SKILL.md
How it compares with Mermaid, D2, draw.io, Excalidraw and archify docs/comparison.md

Contributing

Issues and pull requests are welcome.

To report a bug or ask for a change, open an issue. Include the script, JSON or Mermaid file that shows the problem, and the problem message or picture you got.

To make the change yourself, open a pull request. For a large change, such as a new block or layout, open an issue first so we can agree on the approach before you write the code.

  1. Fork the repo and create a branch.

  2. Make the change. AGENTS.md lists the commands, the rules the code must keep, and what a finished change looks like. It is written for coding agents, and people can follow it the same way.

  3. Run the tests:

    python3 -m unittest discover -s tests
    
  4. If your change alters a picture, rebuild the examples and commit the new SVG and PNG files with the code:

    for f in examples/*.py; do PYTHONPATH=src python3 "$f"; done
    
  5. Open the pull request. Say what changed and why, and attach a picture if the change alters how diagrams look.

New examples use an invented organization, never real company names, logos or data. To add or update a cloud icon, follow "Sources, family versions and attribution" in the cloud-icons skill: each new address must point to a fixed version of the file and return an SVG.

Contributions are released under the MIT license, like the rest of the project.

Contributors

Their backgrounds are on the About page.

Soundtrack

We recommend listening to music by The Gathering Field while you build.

License

MIT, in LICENSE. The bundled Inter font is by The Inter Project Authors, under the SIL Open Font License 1.1, in src/open_diagram/fonts/OFL.txt.

Metadata

Release files for open-diagram 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for open-diagram 0.6.1
File Size Uploaded Provenance Actions
open_diagram-0.6.1.tar.gz 903.9 kB With provenance Details for open_diagram-0.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for open-diagram 0.6.1
File Interpreter ABI Platform Actions
open_diagram-0.6.1-py3-none-any.whl Python 3 none any Details for open_diagram-0.6.1-py3-none-any.whl

Total release size: 1.8 MB

Release files / open_diagram-0.6.1.tar.gz

Download URL open_diagram-0.6.1.tar.gz
Size 903.9 kB
Tags Source
SHA-256 checksum
How to use checksums
934fdff07f4d70937f9a9d7f07967fec4bb75f5f899b1c158cfff9377fa46359
BLAKE2b-256 checksum
How to use checksums
5344e182055cc322e2af2b538aaecd367f27d50e29fa979f9e732ff4daa843db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / open_diagram-0.6.1-py3-none-any.whl

Download URL open_diagram-0.6.1-py3-none-any.whl
Size 898.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f85d9ee4cf49b40f1b5fda945535e6751ca6d3ac9c470ca9741d8005e5c8d1c
BLAKE2b-256 checksum
How to use checksums
7589b2be70c07743b9866f4b0056f177e8891c8fe682b948cb83605e5bb741d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for open-diagram 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for open_diagram-0.6.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page