diagrams
Diagram as Code
What it is and what it does
Diagrams is a Python library for creating cloud architecture diagrams as code rather than using graphical design tools. It supports major cloud providers (AWS, Azure, GCP, Kubernetes, Alibaba Cloud, Oracle Cloud) as well as on-premises nodes, SaaS, and programming frameworks. The library uses Graphviz to render diagrams to image files, allowing you to version-control architecture documentation alongside your infrastructure code.
The package is designed for prototyping new architectures, documenting existing systems, and tracking architecture changes through version control. It does not provision cloud resources or generate infrastructure-as-code templates (Terraform, CloudFormation); it is purely for visualization. It requires Python 3.9+ and a system installation of Graphviz.
Use it for:
- Document cloud architecture designs in version-controlled Python code for team collaboration and change tracking.
- Prototype new system architectures quickly without opening a design tool, iterating on topology in code.
- Generate architecture diagrams programmatically from infrastructure metadata or configuration files.
- Create consistent, reproducible architecture visualizations for documentation and presentations.
- Visualize multi-cloud or hybrid on-premises deployments with a unified diagram format.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Diagrams lets you draw cloud system architecture diagrams programmatically in Python, supporting major cloud providers like AWS, Azure, GCP, Kubernetes, and on-premises infrastructure.
Yes. Diagrams is actively maintained, permissively licensed, has low install friction, and fills a clear need for developers who want to treat architecture diagrams as code. The 42508 repository stars and top-5000 PyPI position confirm real adoption. The only prerequisite is a separate Graphviz installation, which is a one-time setup. Install it if you need to document or prototype cloud architectures programmatically.
Install
diagrams on PyPI
pip
pip install diagramsuv
uv add diagramspoetry
poetry add diagramsInstalling diagrams
Before you install
Low friction: pure Python wheel with four runtime dependencies (graphviz, jinja2, typed-ast, pre-commit). Actively maintained with recent releases; last commit 2026-08-14 and 42508 repository stars indicate stable, well-used project.
License in practice
MIT license (permissive) means you can use, modify, and distribute diagrams freely in commercial or private projects with minimal restrictions.
Quickstart
pip install diagrams
from diagrams import Diagram
from diagrams.aws.compute import EC2
with Diagram("My Architecture"):
EC2("web")
Requires Graphviz to be installed separately on your system (e.g., `brew install graphviz` on macOS, or download from graphviz.org). Python 3.9 or higher required.
Verify before relying
- Whether typed-ast and pre-commit are truly runtime dependencies or development-only (they appear unusual in a diagram rendering library's runtime chain).
- Performance characteristics when rendering large or complex architectures with many nodes and connections.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (~=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — graphviz, jinja2, typed-ast, pre-commit |
| Maintenance | actively maintained — 265 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 7,503,612/month — #1,733 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: diagrams-0.25.1-py3-none-any.whl
Tags
More Graphics packages
Pillow adds image processing capabilities to…
permissive · top 100 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
matplotlib-inlineEnables matplotlib figures to display inline…
permissive · top 1,000 on PyPI
pymupdfPyMuPDF extracts, renders, converts, and…
agpl · top 1,000 on PyPI
pypdfium2pypdfium2 is a Python binding to PDFium that…
permissive · top 1,000 on PyPI
altairAltair is a declarative Python library for…
permissive · top 1,000 on PyPI
pystructurizrPyStructurizr provides a Python DSL for…
permissive · top 15,000 on PyPI
seedirGenerates ASCII tree diagrams of folder…
permissive · top 15,000 on PyPI
cloudbridgeCloudBridge provides a unified Python API that…
permissive · top 15,000 on PyPI
pulumiPulumi's Python SDK lets you define and deploy…
permissive · top 5,000 on PyPI
torchvizGenerates visual diagrams of PyTorch neural…
permissive · top 5,000 on PyPI
graphvizGenerates DOT language source code for graph…
permissive · top 1,000 on PyPI
matplotlib-vennPlots area-weighted two- and three-circle Venn…
permissive · top 15,000 on PyPI
schemdrawSchemdraw generates high-quality electrical…
permissive · top 15,000 on PyPI
django-diagramGenerates Entity Relationship Diagrams in…
unclear · top 15,000 on PyPI
pulumi-gcpPulumi resource provider for Google Cloud…
permissive · top 5,000 on PyPI