Skip to main content

JupyterLab Mermaid to PNG Extension

GitHub Actions npm version PyPI version Total PyPI downloads JupyterLab 4 Brought To You By KOLOMOLO

Export Mermaid diagrams from JupyterLab markdown files as high-quality PNG images. Right-click any rendered diagram in the markdown viewer to copy or save it as a PNG file with configurable resolution settings.

Extension Screenshot

Features

Core capabilities:

  • Copy diagrams directly to clipboard as PNG images
  • Save diagrams as PNG files with deterministic content-based filenames
  • Configurable DPI resolution from 72 to 1200 (default 300)
  • Transparent backgrounds for seamless integration into documents
  • Zero configuration required - works immediately after installation

Technical implementation:

  • Pure client-side rendering using browser canvas API
  • No external services or command-line tools required
  • Calibrated DPI conversion matching Adobe converter output (±0.07% accuracy)
  • Context menu integration in markdown viewer only

Requirements

  • JupyterLab >= 4.0.0

Installation

Install from PyPI using pip:

pip install jupyterlab_mmd_to_png_extension

After installation, restart JupyterLab to activate the extension.

Usage

Open any markdown file containing Mermaid diagrams in JupyterLab. The extension adds two options to the context menu when you right-click on a rendered diagram in the markdown viewer:

Copy as PNG - Copies the diagram to your clipboard as a PNG image. Paste directly into documents, presentations, or image editors.

Save as PNG - Downloads the diagram as a PNG file. Filenames follow the pattern mermaid-<document-name>-<content-hash>.png where the hash is generated from the diagram content, ensuring consistent filenames for identical diagrams.

DPI Configuration

Adjust export resolution through JupyterLab's settings interface. Navigate to Settings -> Advanced Settings Editor -> Mermaid to PNG Extension. The default DPI is 300 (standard print quality), with a range from 72 (screen resolution) to 1200 (professional print quality).

Example

Create a markdown file with a Mermaid diagram:

```mermaid
graph TD
    A[Start] -> B[Process]
    B -> C[End]

Render the markdown file in JupyterLab's viewer. Right-click the diagram and select either "Copy as PNG" or "Save as PNG". The exported image will use your configured DPI setting and include a transparent background.

## Uninstall

Remove the extension using pip:

```bash
pip uninstall jupyterlab_mmd_to_png_extension

Troubleshooting

If the extension is not appearing in the context menu, verify both the server and frontend extensions are properly installed and enabled.

Check server extension status:

jupyter server extension list

Check frontend extension status:

jupyter labextension list

Both should show jupyterlab_mmd_to_png_extension as enabled. If either is missing or disabled, reinstall the extension and restart JupyterLab.

Contributing

Development Setup

Install the extension in development mode. This requires NodeJS for building the TypeScript source code. The jlpm command is JupyterLab's pinned version of yarn.

# Install package in development mode
pip install -e ".[test]"

# Link development version with JupyterLab
jupyter labextension develop . --overwrite

# Enable server extension manually (required in development mode)
jupyter server extension enable jupyterlab_mmd_to_png_extension

# Build the extension
jlpm build

Development Workflow

Run the watch command in one terminal to automatically rebuild on file changes:

jlpm watch

Run JupyterLab in a separate terminal:

jupyter lab

The extension rebuilds automatically when you save changes. Refresh your browser to load the updated extension (allow a few seconds for rebuild completion).

Development Uninstall

Disable the server extension and remove the package:

jupyter server extension disable jupyterlab_mmd_to_png_extension
pip uninstall jupyterlab_mmd_to_png_extension

Remove the symlink created by jupyter labextension develop. Use jupyter labextension list to locate the labextensions folder, then delete the jupyterlab_mmd_to_png_extension symlink within that folder.

Testing

Python tests use Pytest:

pip install -e ".[test]"
pytest -vv -r ap --cov jupyterlab_mmd_to_png_extension

JavaScript tests use Jest:

jlpm
jlpm test

Integration tests use Playwright with the Galata framework for JupyterLab UI testing. See ui-tests/README.md for details.

Release Process

See RELEASE.md for packaging and publishing instructions.

Metadata

Release files for jupyterlab-mmd-to-png-extension 1.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyterlab-mmd-to-png-extension 1.0.11
File Size Uploaded
jupyterlab_mmd_to_png_extension-1.0.11.tar.gz 443.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyterlab-mmd-to-png-extension 1.0.11
File Interpreter ABI Platform
jupyterlab_mmd_to_png_extension-1.0.11-py3-none-any.whl Python 3 none any Details

Total release size: 468.8 kB

Release files / jupyterlab_mmd_to_png_extension-1.0.11.tar.gz

Download URL jupyterlab_mmd_to_png_extension-1.0.11.tar.gz
Size 443.7 kB
Tags Source
SHA-256 checksum
How to use checksums
83b9ba37bb9d78aeb79921e85071dfc96f271a7160b3ee12ecf72fa7221a462f
BLAKE2b-256 checksum
How to use checksums
4b5878b7ae2cdddf011982ca6ee47a1cbaf943071d8e0fa67455015ddb4f39db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / jupyterlab_mmd_to_png_extension-1.0.11-py3-none-any.whl

Download URL jupyterlab_mmd_to_png_extension-1.0.11-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f482ed4d9faee52f4d111de525bc24adf58e6a04efb5728187dda2782413fca5
BLAKE2b-256 checksum
How to use checksums
b672b75d5c3a8c8a9ba96e364f831533ee78c3858de0f078138224b251a75032
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

1.0.11 This release

2 release files

1.0.10

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.4

2 release files

1.0.1

2 release files

0.9.50

2 release files

0.9.46

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page