UML Class Diagram Generator
The UML Class Diagram Generator gives you full visibility into your Python object model by translating your class definitions into clear, standardized diagrams. It’s ideal for:
- Documenting existing codebases without manually drawing diagrams.
- Onboarding new team members with up‑to‑date architectural views.
- Embedding live‑generated diagrams into design documents or README files.
- Automating UML updates in your CI/CD pipeline to prevent drift.
Key Features
- Inheritance (
class Child(Parent):) is represented as a solid arrow with a triangle tip:This helps visualize base classes, mixins, and framework extensions at a glance.Python: class VIPUser(User): … UML: VIPUser --|> User - Associations based on constructor type hints:
Automatically shows how objects reference each other, eliminating manual arrow drawing.
Python: def __init__(self, order: Order): … UML: Customer --> Order - Visibility markers use
+for public members and-for private ones:Clearly distinguishes internal implementation details from API methods.Python: def _calculate(): … UML: - _calculate() - Class attributes & defaults (e.g.
MAX_RETRIES = 3) become fields:Documents constants and configurable settings alongside instance data.Python: MAX_RETRIES = 3 UML: + MAX_RETRIES: int = 3 - Operations (methods) are listed under each class (excluding
__init__):Provides a quick API overview without digging into source code.Python: def process(self): … UML: + process() - Ready‑to‑paste PlantUML: just wrap your output in
@startuml…@endumland render it in any PlantUML-compatible tool.
Before:
class Address():
def __init__(self, street: str, zip: str):
self.street = street
self.zip = zip
class User(Address):
def __init__(self, name: str, address: Address):
super().__init__(address.street, address.zip)
self.name = name
def greet(self):
print(f'Hello {self.name}')After (with all options):
@startuml
class Address {
+ street
+ zip
}
class User {
+ name
+ greet()
}
User --|> Address
User --> Address
@endumlAdvanced Tips
- Selective options: disable “associations” to hide crowded arrows, or disable “visibility” for a cleaner look when privacy details aren’t needed.
- Grouping: use PlantUML’s
packageornamespacefeatures around the output to group related classes. - Custom stereotypes & notes: after generation, you can append PlantUML tags like
<<service>>ornote rightfor additional context. - Embedding in CI: add a step to regenerate diagrams on each push and automatically commit updated
.pumlfiles to keep docs in sync. - Multi‑language support: although tailored for Python, you can adapt the output to other languages’ class syntaxes by minor PlantUML customization.
Once you have the markup:
- Paste into any PlantUML renderer (PlantText, VS Code plugin, IntelliJ PlantUML). Instantly see class layouts and their relationships.
- Embed diagrams inline in Markdown or AsciiDoc files using supported tags (e.g. GitLab’s
```pumlblocks). - Use
skinparamdirectives in PlantUML to adjust fonts, colors, and layout algorithms for consistent styling across projects. - Regenerate diagrams after each code change to maintain accurate architecture docs and avoid outdated visuals.
- Share snapshots in pull requests or design discussions, providing both code and diagram side‑by‑side for faster reviews.