Visualizers

Mermaid Class Diagram Editor

Sketch the classes of a program and how they relate, as UML from plain text.

  • Runs in your browser
  • Instant results
  • Free, no sign-up
Loading the tool…

How to use the Mermaid Live Editor

  1. Declare classes with their fields and methods in braces, after "classDiagram".
  2. Mark visibility with + (public), - (private), # (protected), and connect classes with relationship arrows.
  3. Download SVG or PNG, copy the Markdown block, or copy a share link.

Frequently asked questions

How do I show inheritance in a Mermaid class diagram?

Write "Parent <|-- Child", for example "Animal <|-- Dog". The hollow triangle points at the parent class, as in UML.

What do + and - mean before a field?

Visibility. + is public, - is private, # is protected and ~ is package or internal. Methods end with parentheses and can show a return type after them, like "+getName() String".

What is the difference between composition and aggregation?

Composition (*--) means the part cannot live without the whole, like an engine in a car. Aggregation (o--) means the part can exist on its own, like a player in a team.

Can I draw interfaces and abstract classes?

Yes. Put a stereotype inside the class, such as "<<interface>>" or "<<abstract>>", and connect implementing classes with "..|>".

Syntax cheat sheet

CodeWhat it does
classDiagramStart a class diagram
class Dog { +String name +bark() void }A class with a field and a method (one member per line)
+ - # ~Public, private, protected, package visibility
Animal <|-- DogInheritance: Dog extends Animal
Car *-- EngineComposition: the engine is part of the car
Team o-- PlayerAggregation: a team has players
Order --> CustomerAssociation
Shop "1" --> "*" ProductMultiplicity on a relationship
<<interface>> ShapeA stereotype such as interface or abstract

Practice Python with coding challenges

Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.

All Python challenges
Easy

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

You'll learn ArithmeticReturn values
BeginnerLearning-pathVariables
Easy

Distance Between Points

Compute the straight-line distance between two points.

You'll learn Pythagorean theoremSquare roots
BeginnerFunctionsLearning-pathmath
Easy

Average of Three

Average three whole numbers.

You'll learn ArithmeticDivision
BeginnerLearning-pathVariables
Easy

Prime Number Check

Decide whether a number is prime.

You'll learn DivisibilityLoop optimization
BeginnerLoopsNumbersStudent-beginner
Easy

Dot Product of Two Vectors

Multiply two vectors element by element and add the results: the core operation of every neuron.

You'll learn VectorsDot product
Neural networksaimachine learning
Easy

Days in a Month

Return how many days a month has, including leap years.

You'll learn Calendar rulesHelper functions
BeginnerConditionsFunctionsLearning-path
Easy

Count Uppercase Letters

Count the capital letters in a text.

You'll learn Character checksCounting
BeginnerLearning-pathStrings
Easy

Celsius to Fahrenheit

Convert a temperature from Celsius to Fahrenheit.

You'll learn FormulasOperator precedence
BeginnerLearning-pathVariables
Easy

Min and Max Together

Find the smallest and largest value in one pass.

You'll learn Single passMultiple return values
ArraysBeginnerFunctionsLearning-path
Easy

Largest of Three

Pick the largest of three numbers without a built-in max.

You'll learn ComparisonsCombining conditions
BeginnerConditionsLearning-path
Easy

Swap First and Last

Exchange the first and last items of a list.

You'll learn List indexingSwapping
ArraysBeginnerLearning-path
Easy

Password Rules Check

Check a password against simple strength rules.

You'll learn ValidationBoolean flags
BeginnerConditionsLearning-pathStrings