C4 diagrams are experimental in Mermaid. The syntax and properties may change in future releases. Syntax is compatible with PlantUML.
Diagram types
Mermaid supports five types of C4 diagrams:- System Context (
C4Context) - Shows the system and its users - Container (
C4Container) - Shows high-level technical building blocks - Component (
C4Component) - Shows components within a container - Dynamic (
C4Dynamic) - Shows runtime behavior and collaborations - Deployment (
C4Deployment) - Shows deployment topology
System context diagram
Shows the big picture of the system and how it fits into the world:Container diagram
Shows the high-level technology choices and how containers communicate:Component diagram
Shows how a container is made up of components:Dynamic diagram
Shows how elements collaborate at runtime:Deployment diagram
Shows how containers are deployed to infrastructure:Styling elements
UpdateElementStyle
UpdateElementStyle
Customize the appearance of elements:Example:
UpdateRelStyle
UpdateRelStyle
Customize the appearance of relationships:Example:
UpdateLayoutConfig
UpdateLayoutConfig
Adjust the layout configuration:Example:
Parameter assignment
There are two ways to assign optional parameters (those with? prefix):
Positional parameters
Named parameters
Parameter names must start with$:
Supported elements
System context elements
System context elements
Person(alias, label, ?descr, ?sprite, ?tags, $link)Person_Ext- External personSystem(alias, label, ?descr, ?sprite, ?tags, $link)SystemDb- System databaseSystemQueue- System queueSystem_Ext- External systemSystemDb_Ext- External databaseSystemQueue_Ext- External queueBoundary(alias, label, ?type, ?tags, $link)Enterprise_Boundary(alias, label, ?tags, $link)System_Boundary
Container elements
Container elements
Container(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)ContainerDb- Container databaseContainerQueue- Container queueContainer_Ext- External containerContainerDb_Ext- External databaseContainerQueue_Ext- External queueContainer_Boundary(alias, label, ?tags, $link)
Component elements
Component elements
Component(alias, label, ?techn, ?descr, ?sprite, ?tags, $link)ComponentDb- Component databaseComponentQueue- Component queueComponent_Ext- External componentComponentDb_Ext- External databaseComponentQueue_Ext- External queue
Relationship types
Relationship types
Rel(from, to, label, ?techn, ?descr, ?sprite, ?tags, $link)BiRel- Bidirectional relationshipRel_U,Rel_Up- Upward relationshipRel_D,Rel_Down- Downward relationshipRel_L,Rel_Left- Left relationshipRel_R,Rel_Right- Right relationshipRel_Back- Backward relationship
Limitations
The following features are not currently supported:
- Sprites (custom icons)
- Tags
- Links
- Legend
- Layout statements (Lay_U, Lay_D, Lay_L, Lay_R)
- Custom element and relationship tags (AddElementTag, AddRelTag)