Computer Science · Undergraduate

UML Class Diagram Generator

Free online UML Class Diagram generator: get a fully labeled figure in about 90 seconds. The AI plans the must-have label list first, then renders a clean textbook-style diagram — every label editable afterwards, ready for papers, assignments and slides.

Labels included in this diagram

  • Superclass
  • Subclass
  • Related Class
  • Attributes
  • Operations
  • + public
  • - private
  • # protected
  • Generalization
  • Association
  • Aggregation
  • Composition
  • 1
  • 0..*

Generate this diagram →

✓ Accurate labels ✓ Edit text after generation ✓ PNG for papers, posters & slides

LABELED · EDITABLEUML Class DiagramOUTPUT · 16:9 · PNG
Real output · unedited

What this diagram shows

This UML class diagram models the static structure of an object-oriented system. Each of the three class boxes is divided into three compartments: the class name, attributes, and operations (methods). Visibility symbols indicate access control: + means public, - means private, and # means protected. The diagram also represents several structural relationships. Generalization is shown with a solid line and a hollow triangular arrowhead, while association is a plain structural link. Aggregation uses a hollow diamond to indicate a weak whole–part relationship, and composition uses a filled diamond to indicate strong ownership and dependent lifetimes.

The class compartments identify what an object is and what it can do, while relationship lines explain how objects collaborate or form hierarchies. Inheritance proceeds from a specialized subclass toward a more general superclass; the hollow triangle points to the superclass. An association connects independent classes and may include role names or multiplicities. Aggregation connects a whole to parts that can exist independently, whereas composition connects a whole to parts whose lifecycle is controlled by the whole. Thus, the diagram should be read as a static model of types, accessibility, structure, and responsibility rather than as an execution sequence.

What a correct diagram must include

  • Class name compartment: place the class name at the top and use a clear noun that represents a type of object.
  • Attribute compartment: write each attribute with visibility, name, and type, such as -balance: Money, to define stored state precisely.
  • Operation compartment: write methods with visibility, parameters, and return type, such as +withdraw(amount: Money): Boolean.
  • Visibility symbols: use + for public, - for private, and # for protected consistently to communicate encapsulation.
  • Generalization: draw a solid line ending in a hollow triangular arrowhead that points from the subclass to the superclass.
  • Association: connect classes with a solid line and add role names or multiplicities when the structural meaning requires them.
  • Aggregation and composition: use a hollow diamond for shared, independent parts and a filled diamond for strongly owned parts with dependent lifetimes.

Common mistakes

  • Students often reverse the inheritance arrow; the hollow triangle must point to the more general superclass, not toward the subclass.
  • They may use aggregation and composition interchangeably, although composition implies exclusive ownership and a dependent part lifecycle.
  • They frequently confuse an association line with an inheritance relationship; an association does not mean that one class is a kind of another.
  • They may omit attribute types, operation parameters, or return types, making the class interface ambiguous.
  • They sometimes treat visibility symbols as decoration instead of access constraints, especially confusing protected (#) with private (-).

Teaching tips

Use this diagram after introducing classes and objects, then ask students to identify each compartment before interpreting the relationships. Have them explain why the inheritance arrow points toward the superclass, and compare whether a part can exist independently in aggregation and composition. A useful exercise is to convert a short domain description into three classes and justify every line, diamond, and visibility symbol. Assessment questions can test notation recognition, relationship semantics, encapsulation, and the distinction between static class structure and dynamic object behavior.

FAQ about this diagram

What is the difference between aggregation and composition?

Aggregation is a weak whole–part relationship: the parts can exist independently and may be shared. Composition is strong ownership: a part normally belongs to one whole, and its lifetime depends on that whole.

Where should the hollow triangular inheritance arrow point?

It points to the superclass, which represents the more general concept. The class at the opposite end is the subclass that inherits attributes and operations.

Do all attributes and methods need visibility symbols?

A complete class diagram should show visibility when access control matters. Use + for public, - for private, and # for protected; package visibility may also be represented when the model requires it.

Generate this diagram →

Variations of this diagram

Related generators

All generators