> ## Documentation Index
> Fetch the complete documentation index at: https://iso-topology.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Render a D2 diagram with the CLI

> Install iso-topology, turn a small D2 service graph into an architecture SVG, edit it in local Studio, and publish the diagram in your README.

Create an editable architecture diagram from a four-component service graph. This quickstart takes you from a text file to an SVG, a local Studio edit, and an image you can commit with your code.

Want an image for your README before installing? [Edit a service template in your browser, export SVG and YAML, and add it to GitHub](https://iso-topology.mintlify.site/getting-started/05-publishing.md).

Before starting, complete the [native installation](https://iso-topology.mintlify.site/getting-started/01-install.md) and make sure `isotopo` is available in your terminal. The standalone commands below assume a native installation; npx does not add `isotopo` to PATH. New to the product? [Start with the browser quickstart](https://iso-topology.mintlify.site/quickstart.md).

## 1. Install and check

Use the [native installer or npx launcher](https://iso-topology.mintlify.site/getting-started/01-install.md) for macOS, Linux or Windows. No Go toolchain or model API key is required.

```bash theme={"system"}
isotopo doctor
```

For an immediate editable example, run `isotopo studio`. It creates `architecture.yaml` only if absent and prints the local editor URL. Existing files are preserved. To follow the D2 tutorial, continue below.

Go developers can instead install both binaries with `go install github.com/NexusFox88/iso-topology/cmd/isotopo@latest` and `go install github.com/NexusFox88/iso-topology/cmd/isotopo-mcp@latest`.

## 2. Describe a small architecture

Create a file called `services.d2`:

```d2 services.d2 theme={"system"}
user: User { shape: person }
api: API Gateway
worker: Worker
db: Database { shape: cylinder }

user -> api: HTTPS
api -> worker: enqueue
worker -> db: write
```

D2 computes the layout from the graph. The renderer turns the nodes into
isometric shapes and draws their connections.

## 3. Render it

```bash theme={"system"}
isotopo render services.d2 ./out
```

Open `out/topology.html` in your browser to inspect the diagram. Use
`out/topology.svg` wherever you need a vector image.

> [!TIP]
>
> To inspect the same architecture from above, run
> `isotopo render --projection top services.d2 ./out-plan`.

## 4. Edit and preview the source

```bash theme={"system"}
isotopo serve services.d2
```

Open [http://localhost:8731](http://localhost:8731). Studio provides live source editing and preview. For the full canvas-editing workflow, use YAML; see [Choose a format](https://iso-topology.mintlify.site/guides/choose-format.md). Parseable source edits automatically save to the bound file. See the [Studio guide](https://iso-topology.mintlify.site/guides/studio.md)
for the supported editing operations and save behavior.

Change `API Gateway` to `Public API` in the source editor and check that the label updates. You have now completed the first edit-and-render loop.

## 5. Check and share

Stop the server with Ctrl+C or open another terminal in the same directory.
After reviewing validation results, render again to update the exported files;
Studio saves your source but does not refresh an earlier `./out` export.

```bash theme={"system"}
isotopo validate services.d2
```

Validation returns structured issues with paths and suggestions. Exit code `0`
means clean, `2` means warnings, and `3` means errors. A diagram can render with
warnings; inspect those warnings before publishing it.

```bash theme={"system"}
isotopo render services.d2 ./out
```

Keep `services.d2` in version control. Embed the generated SVG in your README:

```markdown theme={"system"}
![Service architecture](./out/topology.svg)
```

> [card] [Add groups and boundaries](https://iso-topology.mintlify.site/getting-started/03-grouping.md)
>
> Continue the tutorial with nested services and labeled containers.

> [card] [Browse example sources](https://iso-topology.mintlify.site/agent/SAMPLES.md)
>
> Start from an existing scene, then adapt it to your architecture.

## Choose your next workflow

* [Create and revise an architecture diagram with an AI agent](https://iso-topology.mintlify.site/guides/ai-architecture-diagram-workflow.md): start with a service, add a cache, and keep the source and placement for the next revision.
* [Edit a diagram without losing your layout](https://iso-topology.mintlify.site/guides/preserve-diagram-layout.md): save a Studio project and carry manual placement into an agent edit.
* [Rebuild a Mermaid graph as an isometric diagram](https://iso-topology.mintlify.site/articles/mermaid-to-isometric-architecture-diagrams.md): compare three matching graphs and download the authored YAML scenes.

## Worked architecture examples

* [Turn a small app into an architecture diagram](https://iso-topology.mintlify.site/articles/architecture-diagram-from-text.md): a visual walkthrough from first source to the next change.

* [ClickHouse analytics diagram](https://iso-topology.mintlify.site/examples/clickhouse-architecture.md)

* [LangChain agent diagram](https://iso-topology.mintlify.site/examples/langchain-agent-architecture.md)

[简体中文](https://iso-topology.mintlify.site/zh/guides/cli-quickstart.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.