Tiny browser-side Graphviz DOT rendering helpers for notebooks and web views
Project description
Browser notebooks can run JavaScript and WebAssembly, but they can't import arbitrary files from Python site-packages. Embedding the full Graphviz WASM bundle in every cell bloats your notebook. Loading from a CDN on every render breaks offline and locked-down environments.
easydot takes the middle path: it vendors Graphviz WASM, starts a tiny loopback asset server on demand, and lets notebook outputs reference a local URL. Small outputs. No manual setup. Works offline.
Quick Start
uv add easydot
import easydot
easydot.display("digraph { A -> B -> C }")
That's it. The return value has _repr_html_() and _mime_() methods, so it renders automatically as the last expression in a notebook cell.
Source Modes
By default, easydot tries the local server first and falls back to a pinned CDN URL:
easydot.display("digraph { A -> B }", source="auto") # default
easydot.display("digraph { A -> B }", source="local") # local only
easydot.display("digraph { A -> B }", source="cdn") # CDN only
| Mode | Local server | CDN fallback | Best for |
|---|---|---|---|
auto |
yes | yes | Most setups |
local |
yes | no | Air-gapped / offline environments |
cdn |
no | yes | Remote hosts where 127.0.0.1 isn't reachable from the browser |
To change the notebook-wide default without editing every display call, set
EASYDOT_SOURCE before rendering any graphs:
import os
os.environ["EASYDOT_SOURCE"] = "cdn"
The environment variable accepts auto, local, or cdn. It only applies
when source="auto" is used, so explicit source="local" and source="cdn"
calls still win.
Some hosted marimo environments protect marimo's generated iframe file URLs. If CDN mode still shows an authorization error, force a self-contained iframe:
import os
os.environ["EASYDOT_SOURCE"] = "cdn"
os.environ["EASYDOT_IFRAME_MODE"] = "srcdoc"
EASYDOT_IFRAME_MODE accepts auto, marimo, or srcdoc.
marimo Support
easydot works with marimo out of the box. It detects marimo and uses its iframe display helper automatically, since marimo doesn't execute arbitrary inline scripts from plain text/html outputs. All source modes work.
Because of that script policy, iframe=False is not a marimo rendering mode. Use it only when embedding the generated HTML somewhere that already provides layout and executes script tags.
To inspect the bundled demo notebook from a checkout:
uv run marimo edit examples/demo.py
For a read-only local preview:
uv run marimo run examples/demo.py --headless --host 127.0.0.1 --port 2718 --no-token
Then open http://localhost:2718.
Library Integration
For libraries that generate their own HTML, use the lower-level asset API:
from easydot import asset_urls
js_url = asset_urls()["js"]
Then in your browser-side code:
const mod = await import(jsUrl);
const graphviz = await mod.Graphviz.load();
const svg = graphviz.layout("digraph { A -> B }", "svg", "dot");
CLI
easydot ships a small command-line tool:
# Render DOT to HTML on stdout
echo 'digraph { A -> B }' | easydot
# Print local asset server URLs
easydot --urls
Runtime Model
The asset server is intentionally narrow:
- Binds only to
127.0.0.1 - Uses an OS-assigned ephemeral port
- Serves only known packaged files (no directory browsing)
- Sets long-lived cache headers
- Shuts down automatically when the Python process exits
What easydot Is Not
easydot does not call the system dot executable. All rendering happens client-side through WebAssembly. For server-side rendering to files, native Graphviz or the graphviz Python package may be a better fit.
Licensing
The Python code is licensed under BSD-3-Clause.
The vendored browser module (src/easydot/assets/index.js) comes from @hpcc-js/wasm-graphviz, licensed under Apache-2.0. The upstream license is included at src/easydot/assets/LICENSE.hpcc-js-wasm; the pinned version lives in src/easydot/_version.py.
| Component | License |
|---|---|
easydot Python code |
BSD-3-Clause |
| Vendored Graphviz WASM | Apache-2.0 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easydot-0.1.8.tar.gz.
File metadata
- Download URL: easydot-0.1.8.tar.gz
- Upload date:
- Size: 639.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
933ac0084b753978c652cd00eed21f8ab68071c6c730b1dbfe7f9fd3e333d2cb
|
|
| MD5 |
1a0bf31318aac87c2e80ddef9092f2c6
|
|
| BLAKE2b-256 |
0d656cff6e509b26c8c4f97547b65d5a3b47765a51864caf49d48e6b1b6ea1e2
|
Provenance
The following attestation bundles were made for easydot-0.1.8.tar.gz:
Publisher:
publish.yml on pablormier/easydot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easydot-0.1.8.tar.gz -
Subject digest:
933ac0084b753978c652cd00eed21f8ab68071c6c730b1dbfe7f9fd3e333d2cb - Sigstore transparency entry: 1342787300
- Sigstore integration time:
-
Permalink:
pablormier/easydot@7030f10b554a22e4f6bf8bccbce975926d186038 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/pablormier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7030f10b554a22e4f6bf8bccbce975926d186038 -
Trigger Event:
push
-
Statement type:
File details
Details for the file easydot-0.1.8-py3-none-any.whl.
File metadata
- Download URL: easydot-0.1.8-py3-none-any.whl
- Upload date:
- Size: 647.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12ecb8fb5742ee4a53626e33849e517f7626da26d10bc1b1f85721d7b28de2ad
|
|
| MD5 |
936fc0f3981e0ceed1d07c332787a355
|
|
| BLAKE2b-256 |
7e0cb9eba648cd4727af31f3806830fc51c426a2130a65d61c3a5a43635403f1
|
Provenance
The following attestation bundles were made for easydot-0.1.8-py3-none-any.whl:
Publisher:
publish.yml on pablormier/easydot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easydot-0.1.8-py3-none-any.whl -
Subject digest:
12ecb8fb5742ee4a53626e33849e517f7626da26d10bc1b1f85721d7b28de2ad - Sigstore transparency entry: 1342787325
- Sigstore integration time:
-
Permalink:
pablormier/easydot@7030f10b554a22e4f6bf8bccbce975926d186038 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/pablormier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7030f10b554a22e4f6bf8bccbce975926d186038 -
Trigger Event:
push
-
Statement type: