Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

D2 is a modern diagram scripting language that turns text to diagrams.

License

NotificationsYou must be signed in to change notification settings

terrastruct/d2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

D2

A modern diagram scripting language that turns text to diagrams.

Docs |Cheat sheet |Comparisons |Playground |IDE

cidailyreleasechangelognpm versiondiscordtwitterlicense

D2 Playground buttonD2 Studio button
cli.mp4

Table of Contents

What does D2 look like?

vars: {d2-config: {layout-engine:elk# Terminal theme codetheme-id:300  }}network: {cell tower: {satellites: {shape:stored_datastyle.multiple:true    }transmittersatellites->transmitter:sendsatellites->transmitter:sendsatellites->transmitter:send  }online portal: {ui: {shape:hexagon}  }data processor: {storage: {shape:cylinderstyle.multiple:true    }  }cell tower.transmitter->data processor.storage:phone logs}user: {shape:personwidth:130}user->network.cell tower:make calluser->network.online portal.ui:access {style.stroke-dash:3}api server->network.online portal.ui:displayapi server->logs:persistlogs: {shape:page;style.multiple:true}network.data processor->api server

D2 render example

Open inplayground

For more examples, see./docs/examples.

Quickstart

The most convenient way to use D2 is to just run it as a CLI executable toproduce SVGs from.d2 files.

# First, install D2curl -fsSL https://d2lang.com/install.sh| sh -s --echo'x -> y -> z'> in.d2d2 --watch in.d2 out.svg

A browser window will open without.svg and live-reload on changes toin.d2.

Install

The easiest way to install is with our install script:

curl -fsSL https://d2lang.com/install.sh| sh -s --

You can run the install script with--dry-run to see the commands that will be usedto install without executing them.

Or if you have Go installed you can install from source though you won't get the manpage:

go install oss.terrastruct.com/d2@latest

You can also install a release from source which will include manpages.See./docs/INSTALL.md#source-release.

To uninstall with the install script:

curl -fsSL https://d2lang.com/install.sh| sh -s -- --uninstall

For detailed installation docs, see./docs/INSTALL.md.We demonstrate alternative methods and examples for each OS.

As well, the functioning of the install script is described in detail to alleviate anyconcern of its use. We recommend using your OS's package manager directly instead forimproved security but the install script is by no means insecure.

D2 as a library

In addition to being a runnable CLI tool, D2 can also be used to produce diagrams fromGo programs.

For examples, see./docs/examples/lib. Thisblogpost also demos acomplete, runnable example of using D2 as a library for a real-world use case.

Themes

D2 includes a variety of official themes to style your diagrams beautifully right out ofthe box. See./d2themes to browse the available themes and make orcontribute your own creation.

Fonts

D2 ships with "Source Sans Pro" as the font in renders. If you wish to use a differentone, please see./d2renderers/d2fonts.

Export file types

D2 currently supports SVG, PNG and PDF exports. More coming soon.

Language tooling

D2 is designed with language tooling in mind. D2's parser can parse multiple errors from abroken program, has an autoformatter, syntax highlighting, and we have plans for LSP's andmore. Good language tooling is necessary for creating and maintaining large diagrams.

The extensions for VSCode and Vim can be found in theRelated section.

Plugins

D2 is designed to be extensible and composable. The plugin system allows you tochange out layout engines and customize the rendering pipeline. Plugins can either bebundled with the build or separately installed as a standalone binary.

Layout engines:

  • dagre (default, bundled): A fast, directed graphlayout engine that produces layered/hierarchical layouts. Based on Graphviz's DOTalgorithm.
  • ELK (bundled): A directed graph layout engineparticularly suited for node-link diagrams with an inherent direction and ports.
  • TALA (binary): Novel layout engine designedspecifically for software architecture diagrams. Requires separate install, visit theGithub page for more.

D2 intends to integrate with a variety of layout engines, e.g.dot, as well assingle-purpose layout types like sequence diagrams. You can choose whichever layout engineyou like and works best for the diagram you're making.

Comparison

For a comparison against other popular text-to-diagram tools, seehttps://text-to-diagram.com.

Contributing

Contributions are welcome! See./docs/CONTRIBUTING.md.

License

Open sourced under the Mozilla Public License 2.0. See./LICENSE.txt.

Related

We are constantly working on new plugins, integrations, extensions. Contributions arewelcome in any official or community plugins. If you have somewhere in your workflow thatyou want to use D2, feel free to open a discussion. We have limited bandwidth and usuallychoose the most high-demand ones to work on. If you make something cool with D2 yourself,let us know and we'll be happy to include it here!

Official plugins

Community plugins

Misc

FAQ

  • Does D2 collect telemetry?
    • No, D2 does not use an internet connection after installation, except to check forversion updates from Github periodically.
  • Does D2 need a browser to run?
    • No, D2 can run entirely server-side.
  • What's coming in the next release?
  • I have a question or need help.
  • I have a feature request, proposal, or bug report.
    • Please open up a Github Issue.
  • I have a private inquiry.

Notable open-source projects documenting with D2

Do you have or see an open-source project with.d2 files? Please submit a PR adding tothis selected list of featured projects using D2.


[8]ページ先頭

©2009-2025 Movatter.jp