Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

This module allows you to generate SVG diagrams from D2 syntax. It includes a text filter to embed these diagrams directly into your Drupal content. You can also generate SVGs programmatically for more advanced use cases.

Introduction

This module provides methods to generate SVGs using D2 diagram syntax.

The primary use case for this module is:

  • Generating diagrams using D2 syntax

A submodule also provides a text filter that allows embedding D2 diagrams in content.

Usage

The easiest way to get started with D2 is to enable the d2_filter submodule and configure a text format to use it.

For more advanced use-cases, you can generate SVGs from D2 like so:

use Drupal\d2\D2Helper;

# Generate an SVG or use a cached copy if available (highly recommended).
$svg = (new D2Helper())->getSvg($d2_input, $d2_options);

If you want an uncached SVG, call the underlying library:

use Consensus\PhpD2\D2;

# Generate an SVG.
$svg = (new D2())->generateSvg($d2_input, $d2_options);

Similar projects

MermaidJS is a mature Javascript library that generates diagrams and charts in-browser. Drupal support is provided by the Mermaid Integration module.

Supporting this module

Contact the module maintainers if you'd like to support development, or request a specific feature.

Community documentation

For more information, check out the D2 website and documentation.

Maintainers

Current maintainers for Drupal 11:

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
8
Tracked since
Jan 2026
Latest release
6 months ago
Releases (12 mo)
8 ▲ from 0
Maintenance
Slowing

Release Timeline

Releases

Version Type Core Release date
1.0.0-beta0 Pre-release 11 Feb 4, 2026
1.0.0-alpha5 Pre-release 11 Jan 13, 2026
1.0.0-alpha4 Pre-release 11 Jan 12, 2026
1.0.0-alpha3 Pre-release 11 Jan 9, 2026
1.0.0-alpha2 Pre-release 11 Jan 8, 2026
1.0.0-alpha1 Pre-release 11 Jan 6, 2026
1.0.0-alpha0 Pre-release 11 Jan 5, 2026
1.0.x-dev Dev 11 Jan 1, 2026