clean Technical Diagramming Library¶
The built-in clean library provides a cohesive, flat diagramming aesthetic
inspired by the Anthropic and OpenAI design languages: a restrained
cool-neutral tint scale that groups components by tint and shape, a single clay
accent reserved for emphasis, hairline borders, and no drop shadows. Enable it
by passing library="clean" to d2.compile().
import d2
svg = d2.compile(code, library="clean")
Use the clean library for:
System and architecture diagrams - services, gateways, APIs, and clients
Data planes - databases, caches, queues, and object storage
AI/agent flows - models, agents, and document artifacts
Control flow - decisions, processes, and grouped boundaries
Differentiation is carried by tint (paper for compute/actors/AI/logic, slate for
data, muted-dashed for external systems) and shape, with the clay accent applied
only to emphasis nodes (clean-primary) and primary paths
(clean-flow-primary).
Example¶
direction: right
title: Request Flow { class: clean-title }
system: Platform {
class: clean-panel
user: User { class: clean-user }
web: Web App { class: clean-browser }
gw: API Gateway { class: clean-gateway }
data: Data Plane {
class: clean-band
api: Orders API { class: clean-primary }
cache: Redis { class: clean-cache }
db: Postgres { class: clean-database }
}
ext: Payments { class: clean-external }
user -> web { class: clean-flow }
web -> gw { class: clean-flow }
gw -> data.api { class: clean-flow-primary }
data.api -> data.cache { class: clean-flow-muted }
data.api -> data.db { class: clean-flow }
data.api -> ext: webhook { class: clean-flow-dashed }
}
Component Classes¶
Class |
Use |
|---|---|
|
Generic service or component box (paper). |
|
Emphasized or primary node, carrying the clay accent. |
|
API or endpoint. |
|
Gateway or ingress (hexagon). |
|
Function, lambda, or handler. |
|
Cloud or managed service (cloud shape). |
|
Relational or primary datastore (cylinder, slate tint). |
|
Cache layer (slate tint). |
|
Object or blob storage (cylinder, slate tint). |
|
Message queue or stream (slate tint). |
|
Generic client. |
|
Web client. |
|
Mobile client. |
|
End user (person shape). |
|
Third-party or external system (muted fill, dashed border). |
|
Model or inference endpoint. |
|
Agent. |
|
Document or artifact (page shape). |
|
Branch or decision point (diamond). |
|
Process or step. |
|
Transparent grouping container with a hairline boundary. |
Panel, Typography, and Flow Classes¶
Use clean-panel for the outer grouped surface and clean-band for a
slate-tinted sub-grouping (for example a data plane or subsystem).
Use clean-title, clean-subtitle, clean-label,
clean-section-label, and clean-note for text-only labels.
Use clean-flow for standard arrows, clean-flow-primary for the
clay-accented primary path, clean-flow-muted for low-emphasis links, and
clean-flow-dashed for optional, asynchronous, or external links.
Dark Theme¶
The clean library supports the same dark theme mode as the other libraries:
svg = d2.compile(code, library="clean", theme="dark")