New: TypeFire 7 and TypeFire for Chrome 2.0.
Free · Live examples · No sign-up

Mermaid class diagrams, written as code

A class diagram shows the parts of a system and how they relate. In Mermaid each class is a block of fields and methods, and each relationship is one line. Edit the example and it redraws.

Free in your browser. On a Mac, TypeFire opens every .md file like this, right from Finder.Download free for Mac

Class diagram.md
FileEditViewInsertFormatHelp
Class diagram.md

Library model

1*borrows1*Library+String name+addBook(Book)Book+String title+String author+checkOut()Member+String name+borrow(Book)
1*borrows1*Library+String name+addBook(Book)Book+String title+String author+checkOut()Member+String name+borrow(Book)

Try this

  • Add class Loan with a +Date due field.
  • Join it with Member "1" --> "*" Loan.
Loading the editor…Your files stay in your browser
  • Your files never leave your browser
  • Free, no sign-up
  • Download as Markdown, Word, a web page or a PDF

This editor comes from TypeFire, free for Mac

Your whole folder of Markdown notes in tabs, Quick Look previews in Finder, plus a text expander and a clipboard manager.

How it works

Write a Mermaid class diagram

  1. 01

    Declare classes

    Start with classDiagram, then class Book { ... } with one member per line inside the braces.

  2. 02

    Mark visibility

    Start a member with + for public, - for private, # for protected or ~ for package. Add () for a method.

  3. 03

    Relate them

    One line per relationship. The symbol in the middle sets the kind, and quoted numbers set how many.

Mermaid class diagram text on the left becomes a drawn diagram of Library, Book and Member classes
Free for Mac and Chrome

Diagrams in your notes? Get TypeFire.

On the Mac, every Mermaid block in your notes draws in TypeFire's colors. Open one full window to zoom in, resize it, link a box to another note, and save it as SVG or PNG.

Download free for MacAdd to Chrome7 day Pro trial, no card required.

Free text expander, markdown notes and a clipboard manager. $18 once for unlimited clips, notes sync and AI prompts.

At a glance

Relationships at a glance

The arrow in the middle of the line sets the relationship.

A <|-- B
B inherits from A
A *-- B
A is made of B (composition)
A o-- B
A has B (aggregation)
A --> B
A uses B (association)
A ..> B
A depends on B
A ..|> B
A implements B
A "1" --> "*" B
One A to many B

Drawn from the example above

What it does

Class diagram tips

  1. Start small

    Draw the three or four classes that matter for the question at hand, not the whole codebase.

  2. Say how many

    "1" and "*" on either side of a line tell readers one library holds many books.

  3. Label the line

    Add : borrows at the end of a relationship to say what it means.

  4. Generics work

    Write List~Book~ for a generic type and it draws as List<Book>.

A Markdown document with a diagram downloaded as a PDF with the diagram drawn in it
Take it further

The same editor, without the browser tab

This editor comes from TypeFire, a free app for Markdown notes, a text expander and a clipboard manager. Here it works on the files you open. In the app, it opens your whole folder.

TypeFire for Mac with several Markdown notes open in one tab bar

TypeFire for Mac

  • Press Space on any .md file in Finder and read it rendered, with Quick Look.
  • Open a folder of Markdown, an Obsidian vault included, with tabs, search and links.
  • A text expander and a clipboard history in the same free app.
In a browser email, typing thx and a space expands into a whole thank-you reply

TypeFire for Chrome

  • This editor in its own tab, one click from the toolbar.
  • Your folder of .md notes in tabs, with search and links.
  • A text expander and your clipboard history on every site.

Frequently asked questions

Still not answered?

Write a Mermaid classDiagram in a code block marked mermaid.

Declare each class with its members, then add one line per relationship.

Use <|-- with the parent on the left: Animal <|-- Dog means Dog inherits from Animal.

*-- is composition: the part can't exist without the whole. o-- is aggregation: the part can exist on its own.

Start it with a minus sign, like -String password. + is public, # protected and ~ package.

Yes. Put quoted values on either side of the line: Library "1" o-- "*" Book.

Design docs with real diagrams

TypeFire for Mac draws class diagrams in your notes, with a viewer to zoom in on the big ones. Free.

Download free for MacAdd to ChromeSee what $18 adds7 day Pro trial, no card required.

Free text expander, markdown notes and a clipboard manager. $18 once for unlimited clips, notes sync and AI prompts.

your clips your snippets