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.61.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.61-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyuml2svg-0.4.61.tar.gz
  • Upload date:
  • Size: 15.9 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.61.tar.gz
Algorithm Hash digest
SHA256 32cc502ad9d7e573dc983b5c7c30815adda75115fa46af610de6ab2644df448d
MD5 10b35ecfbbb5e08c03dedbcf39f94b76
BLAKE2b-256 8f323df7d1e315748e9a983eedb24a053fc59fd1b773ef9ab1b1296d22ab229d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyuml2svg-0.4.61-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.61-py3-none-any.whl
Algorithm Hash digest
SHA256 4a95720a078cef483a71a4125506070705c7757984c1cdf468c0fbaee55ff740
MD5 37c0c56cfdeae2d77dfaa0f0d6b591c5
BLAKE2b-256 becc4e04e7f6458a3166a342ef3f825a5e947a42f975f4077c488a94f327467f

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