Skip to main content

Pure Python UML class diagram generator that renders SVG without dependencies.

Project description

pyuml2svg

pyuml2svg is a pure-Python library that generates UML class diagrams as SVG with no external dependencies.
It performs its own layout, places labels, draws canonical UML relationship arrows, and includes interactive collapse/expand controls directly in the SVG.


Features

  • Zero dependencies — pure Python + SVG
  • Automatic portrait DAG layout
  • Collision-aware edge labels
  • Canonical UML markers (inheritance, composition, aggregation, etc.)
  • Interactive collapse/expand of class hierarchies
  • Disconnected-class highlighting
  • Packaged CSS and JavaScript assets (no external files required)

Installation

pip install pyuml2svg

Quick example

from pyuml2svg import UMLClass, UMLRelation, render_svg_string

classes = [
    UMLClass("Animal"),
    UMLClass("Dog"),
    UMLClass("Cat"),
    UMLClass("Spider"),
]

relations = [
    UMLRelation("Animal", "Dog", kind="inheritance"),
    UMLRelation("Animal", "Cat", kind="directed-association"),
    UMLRelation("Animal", "Spider"),
]

svg = render_svg_string(classes, relations)
with open("diagram.svg", "w", encoding="utf-8") as f:
    f.write(svg)

Open diagram.svg in any browser.

UML Relationship types

Supported kind values:

  • inheritance
  • realization
  • composition
  • aggregation
  • dependency
  • directed-association
  • association
  • link (plain line)

NB. Some of these are still WIP.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyuml2svg-0.4.3.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyuml2svg-0.4.3-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file pyuml2svg-0.4.3.tar.gz.

File metadata

  • Download URL: pyuml2svg-0.4.3.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyuml2svg-0.4.3.tar.gz
Algorithm Hash digest
SHA256 97b3af2d5d1f0b3feee64e8568dc3cdd237dfc1180a079e793450533d11893a8
MD5 d8741d305047e11386f6fe9986687db3
BLAKE2b-256 57375f2ab61ac52eb12cbf30bb8867678c54162060c5741a7d61bf3fe4645cb8

See more details on using hashes here.

File details

Details for the file pyuml2svg-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: pyuml2svg-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyuml2svg-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 84b8f9f49017604c880b214719702de04aaad94f1728ce3e73e979d0c49d830d
MD5 987571303916dedf03daaec9b4750bfb
BLAKE2b-256 5dda87ced2584d5ba2644a48d05dbe3d0b98428cd0ed19da96629477e43c0b03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page