All diagram types Open editor

merIDK / Diagram types / C4 diagram

Mermaid C4 diagram: example and syntax

The C4 model describes software architecture at four zoom levels: context, container, component and code. A context diagram is the top level: your system, the people who use it and the systems around it.

Open this example in the editor

Example code

C4Context
    title Online banking
    Person(customer, "Customer", "Holds an account")
    System(bank, "Banking app", "Lets customers manage money")
    System_Ext(mail, "Email service", "Sends notifications")
    Rel(customer, bank, "Uses")
    Rel(bank, mail, "Sends email via")

Result

C4Context
    title Online banking
    Person(customer, "Customer", "Holds an account")
    System(bank, "Banking app", "Lets customers manage money")
    System_Ext(mail, "Email service", "Sends notifications")
    Rel(customer, bank, "Uses")
    Rel(bank, mail, "Sends email via")

Syntax quick reference

How to use it

  1. Open the example in the editor, or paste your own Mermaid code.
  2. Edit the code on the left. The preview updates as you type, and errors point to the line.
  3. Export SVG or PNG, copy a Markdown block for GitHub or Notion, or copy a share link.

More diagram types