Skip to main content

Tiny browser-side Graphviz DOT rendering helpers for notebooks and web views

Project description

easydot

Graphviz in the browser. Zero installs. One line of Python.

Python 3.10+ License: BSD-3-Clause No Dependencies marimo


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

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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easydot-0.1.3.tar.gz (636.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easydot-0.1.3-py3-none-any.whl (644.4 kB view details)

Uploaded Python 3

File details

Details for the file easydot-0.1.3.tar.gz.

File metadata

  • Download URL: easydot-0.1.3.tar.gz
  • Upload date:
  • Size: 636.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for easydot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 79d706b4bb9c3e0acd3f24074eebc030c53b150400bb27456992bf4e7470e0d3
MD5 1f0618a49ebd65f25147f420e4970f1a
BLAKE2b-256 334af1a99e36a1687b9548c5f3d34bc68f17e14c7d34124bb9a9146fe5a755da

See more details on using hashes here.

Provenance

The following attestation bundles were made for easydot-0.1.3.tar.gz:

Publisher: publish.yml on pablormier/easydot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file easydot-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: easydot-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 644.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for easydot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 45b823ab738d6b9406c961e08565574158cdad1fd6fae15fbd8c8853e2f336f5
MD5 50faade8f0a1fb6605e7e8abb562d5d0
BLAKE2b-256 dac12e9dbfd50c25f8c37a12d023baf51f530e043f982ac6a1e6f2e02c0ab4f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for easydot-0.1.3-py3-none-any.whl:

Publisher: publish.yml on pablormier/easydot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page