D2 Widget
A Python widget that eliminates the friction of creating diagrams in notebooks by integrating the D2 declarative language directly into Jupyter and Marimo. It restores the interactive workflow by providing live, text-based diagramming with inline previews, removing the need for external tools and context switching.
The workflow for creating diagrams in computational notebooks is often a broken experience. It forces a context switch to external tools, reducing a dynamic process of thought and exploration into a static one of importing and managing images. This interruption breaks the very interactive loop that makes notebooks a powerful environment for analysis and documentation.
This widget was created to solve that problem by bringing the diagramming process back into the notebook. It integrates the declarative diagram language
The implementation is designed to feel native to the notebook. It uses
Stack
While the problem is more important than the tools, the tech stack tells a story about the project's architecture and trade-offs. Here's what this project is built on:
Platforms & Runtimes
Frontend & Visualization
Powers the interactive playground application for testing and demonstrating D2 diagram capabilities and bindings supported by d2-widget
Environment for running and displaying the d2-widget within notebook cells
Enables communication between the Python backend and JavaScript frontend for rendering D2 diagrams
External Services
Cloud & DevOps
Development Tooling
Fast Python package installer and resolver for managing Python dependencies and virtual environments
Fast Python linter and formatter for maintaining code quality in the widget backend
Build backend for packaging the Python widget with integrated JavaScript assets
Fast package manager for managing JavaScript dependencies and build artifacts
Bundles TypeScript widget code into optimized JavaScript modules for notebook integration
Provides code formatting and linting for JavaScript/TypeScript frontend code