spinagram

Getting started

Install spinagram and render your first diagram.

Install

spinagram needs Python 3.11 or newer.

pip install "spinagram[all]"         # or: uv add "spinagram[all]"
playwright install chromium          # only for PNG output

The base package renders SVG. Extras add the rest:

ExtraAdds
pptxPowerPoint output
pngPNG output (Playwright)
vectorTraces PNG icons into SVG
uispinagram serve, the live preview
allEverything above

Write a diagram

Save this as web.py:

web.py
from spinagram import Diagram

d = Diagram("W01", "My web app")

users = d.box("Users", icon="aws:users")
with d.group("AWS", style="aws-cloud", direction="right"):
    api = d.box("API", text="FastAPI", icon="terrastruct:python")
    db = d.box("Database", text="PostgreSQL", icon="terrastruct:postgres")

users.to(api, "HTTPS") >> db

d.save("out/", formats=["svg", "png", "pptx"])

Render it

python web.py

out/ now holds W01-my-web-app.svg, its PNG and diagrams.pptx. Icon packs are downloaded into ~/.cache/spinagram/icons the first time a diagram uses them.

Preview while you edit

spinagram serve web.py

A browser tab opens and re-renders every time you save. For spinagram serve and spinagram render to find the diagram, keep diagram = d at the end of the file and guard the save with if __name__ == "__main__":, like examples/quickstart.py.

In Jupyter, a Diagram as the last expression of a cell shows inline.

Where next

On this page