C4 Architecture

JSON schema reference

Every object of the workspace format, generated from c4.schema.json (JSON Schema 2020-12) when this site is built. All objects are closed: an unknown field is an error.

Point your editor to the schema for completion and validation: "$schema": "path/to/schema/c4.schema.json". Rules the schema cannot express are listed in Validation rules.

Structure

workspace
├── version, name, description, include[]
├── model
│   ├── people[]            person
│   ├── softwareSystems[]   softwareSystem
│   │   └── containers[]    container
│   │       └── components[] component
│   └── relationships[]     relationship
├── views[]                 view (by type)
└── styles
    ├── elements[]          elementStyle
    └── relationships[]     relationshipStyle

Workspace and model

Workspace (root)

C4 model (context, container and component levels) and its views. Derived from the Structurizr DSL. A file included via include uses the same schema.

FieldTypeDescription
$schemastringPath or URL of this JSON Schema, for editor support. Ignored by the runtime.
version required1Format version.
namestringWorkspace name, used as the page title. Must not be empty.
descriptionstringWorkspace description, shown under the page title.
includearray of relative pathFiles merged into this workspace. Paths are relative to the current file; remote URLs are not allowed.
modelmodelThe elements and their relationships.
viewsarray of viewDiagrams to render, in page order.
stylesstylesElement and relationship styles, matched by tag.

Model

FieldTypeDescription
impliedRelationshipsbooleanDerive relationships between parents from relationships between their children (Structurizr default behaviour). Default: true.
peoplearray of personPeople: the users or roles that interact with the software systems.
softwareSystemsarray of softwareSystemSoftware systems, internal or external, with their containers.
relationshipsarray of relationshipEvery relationship of the model, between any two elements.

Person

FieldTypeDescription
id requiredidIdentifier referenced by relationships, views and steps. Unique across the whole workspace.
name requiredstringName shown on the diagram. Must not be empty.
descriptionstringWho this person or role is, shown on the diagram.
externalbooleanElement outside the organisation or team scope (rendered grey, per C4 notation). Default: false.
groupstringName of a group. Elements sharing a group are drawn inside a dashed frame. Must not be empty.
tagstagsUser tags. Default tags (Element, Person, Software System, Container, Component, Relationship) are implicit.
urlURLLink opened when the element is clicked. http and https only.
propertiespropertiesFree-form metadata, not rendered.

Software system

FieldTypeDescription
id requiredidIdentifier referenced by relationships, views and steps. Unique across the whole workspace.
name requiredstringName shown on the diagram. Must not be empty.
descriptionstringWhat the system does, shown on the diagram.
externalbooleanElement outside the organisation or team scope (rendered grey, per C4 notation). Default: false.
groupstringName of a group. Elements sharing a group are drawn inside a dashed frame. Must not be empty.
tagstagsUser tags. Default tags (Element, Person, Software System, Container, Component, Relationship) are implicit.
urlURLLink opened when the element is clicked. http and https only.
propertiespropertiesFree-form metadata, not rendered.
containersarray of containerContainers of the system (C4 level 2).

Container

FieldTypeDescription
id requiredidIdentifier referenced by relationships, views and steps. Unique across the whole workspace.
name requiredstringName shown on the diagram. Must not be empty.
descriptionstringResponsibility of the container, shown on the diagram.
technologystringMain technology choice (e.g. "Go", "React", "PostgreSQL 16"), shown under the name.
groupstringName of a group. Elements sharing a group are drawn inside a dashed frame. Must not be empty.
tagstagsUser tags. Default tags (Element, Person, Software System, Container, Component, Relationship) are implicit.
urlURLLink opened when the element is clicked. http and https only.
propertiespropertiesFree-form metadata, not rendered.
componentsarray of componentComponents of the container (C4 level 3).

Component

FieldTypeDescription
id requiredidIdentifier referenced by relationships, views and steps. Unique across the whole workspace.
name requiredstringName shown on the diagram. Must not be empty.
descriptionstringResponsibility of the component, shown on the diagram.
technologystringMain technology choice (e.g. "Go", "React", "PostgreSQL 16"), shown under the name.
groupstringName of a group. Elements sharing a group are drawn inside a dashed frame. Must not be empty.
tagstagsUser tags. Default tags (Element, Person, Software System, Container, Component, Relationship) are implicit.
urlURLLink opened when the element is clicked. http and https only.
propertiespropertiesFree-form metadata, not rendered.

Relationship

FieldTypeDescription
ididOptional. Only needed to target the relationship in include/exclude.
from requiredidId of the source element: the one that initiates the interaction.
to requiredidId of the destination element.
descriptionstringWhat the source does with the destination, as a verb phrase (e.g. "Places orders using").
technologystringProtocol and format (e.g. "HTTPS/JSON", "gRPC", "SQL").
tagstagsUser tags. Default tags (Element, Person, Software System, Container, Component, Relationship) are implicit.
urlURLLink opened when the relationship is clicked. http and https only.
propertiespropertiesFree-form metadata, not rendered.

Views

A view is one of the five objects below, chosen by its type. See Views for what each one shows.

systemLandscape view

Landscape: every person and software system, with no central system.

FieldTypeDescription
type requiredsystemLandscapeView type.
key requiredidUnique view identifier (used as the HTML anchor).
titlestringTitle shown above the diagram and in the page navigation. Defaults to the key.
descriptionstringText shown under the title.
includearray of selectorDefaults to ["*"].
excludearray of selectorSelectors removed from the selection. Removing an element also removes its relationships.
layoutlayoutAutomatic layout options.

systemContext view

Level 1: a software system and its direct surroundings.

FieldTypeDescription
type requiredsystemContextView type.
key requiredidUnique view identifier (used as the HTML anchor).
scope requiredidId of a softwareSystem.
titlestringTitle shown above the diagram and in the page navigation. Defaults to the key.
descriptionstringText shown under the title.
includearray of selectorDefaults to ["*"].
excludearray of selectorSelectors removed from the selection. Removing an element also removes its relationships.
layoutlayoutAutomatic layout options.

container view

Level 2: the containers of a software system.

FieldTypeDescription
type requiredcontainerView type.
key requiredidUnique view identifier (used as the HTML anchor).
scope requiredidId of a softwareSystem.
titlestringTitle shown above the diagram and in the page navigation. Defaults to the key.
descriptionstringText shown under the title.
includearray of selectorDefaults to ["*"].
excludearray of selectorSelectors removed from the selection. Removing an element also removes its relationships.
layoutlayoutAutomatic layout options.

component view

Level 3: the components of a container.

FieldTypeDescription
type requiredcomponentView type.
key requiredidUnique view identifier (used as the HTML anchor).
scope requiredidId of a container.
titlestringTitle shown above the diagram and in the page navigation. Defaults to the key.
descriptionstringText shown under the title.
includearray of selectorDefaults to ["*"].
excludearray of selectorSelectors removed from the selection. Removing an element also removes its relationships.
layoutlayoutAutomatic layout options.

dynamic view

Dynamic: a numbered sequence of interactions, each step being an instance of a relationship of the model (declared or implied).

FieldTypeDescription
type requireddynamicView type.
key requiredidUnique view identifier (used as the HTML anchor).
scopeidId of a softwareSystem (steps between containers) or a container (steps between components). Omit it for steps between people and software systems.
titlestringTitle shown above the diagram and in the page navigation. Defaults to the key.
descriptionstringText shown under the title.
steps requiredarray of dynamicStepSteps, numbered from 1 in array order. Must not be empty.
layoutlayoutAutomatic layout options.

View details and styles

Dynamic step

One interaction. A relationship from from to to must exist in the model.

FieldTypeDescription
from requiredidId of the source element.
to requiredidId of the destination element.
descriptionstringWhat happens at this step. Defaults to the description of the relationship; also selects the relationship when several link the same elements.

Layout

Automatic layout options.

FieldTypeDescription
directionTB | BT | LR | RLRank direction: TB top to bottom, BT bottom to top, LR left to right, RL right to left. Default: TB.
rankSeparationinteger ≥ 0Space between ranks, in pixels (default 64).
nodeSeparationinteger ≥ 0Space between elements of the same rank, in pixels (default 48).

Styles

FieldTypeDescription
elementsarray of elementStyleElement styles. An element takes the styles of its tags, in tag order; later ones win, property by property.
relationshipsarray of relationshipStyleRelationship styles, applied like element styles.

Element style

Style applied to elements with the tag. No shadows: no property allows them.

FieldTypeDescription
tag requiredstringTag the style applies to. Default tags (Element, Person, Software System, Container, Component) work too. Must not be empty.
shapebox | roundedBox | person | cylinder | pipe | component | webBrowser | mobileDevicePortrait | folderShape of the element. Default: person for people, roundedBox otherwise.
iconstringEmbedded image only (data URI), to stay self-contained.
widthinteger ≥ 1Width in pixels (default 240).
heightinteger ≥ 1Minimum height in pixels (default 120). The box grows to fit its text.
backgroundcolourFill colour. Default: C4 blue by level, grey for external elements.
colorcolourText colour.
strokecolourBorder colour.
strokeWidthinteger, 1–10Border width in pixels (default 1).
bordersolid | dashed | dottedBorder line style (default solid).
opacityinteger, 0–100Opacity in % (default 100).
fontSizeinteger ≥ 1Font size of the name, in pixels (default 14). Metadata and description are slightly smaller.
metadatabooleanShow the element type and technology (default true).
descriptionbooleanShow the description (default true).

Relationship style

FieldTypeDescription
tag requiredstringTag the style applies to. The default tag Relationship works too. Must not be empty.
colorcolourColour of the line and its label.
thicknessinteger, 1–10Line width in pixels.
stylesolid | dashed | dottedLine style (default solid).
routingdirect | orthogonal | curvedorthogonal (default): right angles with rounded corners; curved: fully rounded corners; direct: straight line.
fontSizeinteger ≥ 1Font size of the label, in pixels (default 11).
widthinteger ≥ 1Maximum label width, in pixels (default 160).
positioninteger, 0–100Label position along the line, in % from the source (default 50).
opacityinteger, 0–100Opacity in % (default 100).

Common types

id

Identifier unique across the whole workspace (included files too). Pattern: ^[A-Za-z][A-Za-z0-9_-]*$.

relative path

Path relative to the declaring file. Absolute paths and URLs are not allowed.

colour

Colour in #RRGGBB hexadecimal notation.

tags

User tags. Default tags (Element, Person, Software System, Container, Component, Relationship) are implicit. An array of non-empty strings, without duplicates.

selector

Used in include and exclude. One of:

FormSelects
*The default selection of the view type.
"<id>"One element, by id.
{ "tag": … }Every element with this tag. In exclude, relationships with this tag are removed too.
{ "relationship": … }A relationship by id. In include, adds both of its ends; in exclude, removes the relationship.

Property

FieldTypeDescription
name requiredstringProperty name. Must not be empty.
value requiredstringProperty value.