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.6.tar.gz (15.8 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.6-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyuml2svg-0.4.6.tar.gz
Algorithm Hash digest
SHA256 2f401ee78cdf65f8e9696f2094165b61401b7e741034fb284a3e95f7d928d400
MD5 6f318579a618133eae603a8545ba62bc
BLAKE2b-256 f11e6482eb730674a04b08148be09873534783ebf450b24cb8e3478ebba2aca8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyuml2svg-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5c448f8f5ef3181dcf05401a9306e19a73e12007d892abf2d5ef3682b07da97e
MD5 4852a5296d094bb209c32f85fb94370c
BLAKE2b-256 3eddaa56ca85db6b850b7b2a05b9e512ccc6c5b260d0ebb2bba08d27c7c04dee

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