CLI tool to generate high-quality PNG snapshots from n8n workflow JSON files using Playwright
Project description
n8n Workflow Snapshot Generator
Generate high-quality PNG snapshots of n8n workflows using Python and Playwright.
Features
- Dark Mode Support - Render workflows with light or dark theme
- Flexible Dimensions - Square, widescreen, or custom aspect ratios
- High Quality - 2x retina resolution for crisp images
- Iframe-only Capture - Clean workflow screenshots without page chrome
- Batch Processing - Process multiple workflows at once
- In-Place Mode - Save images alongside source JSON files with status tracking
- Parallel Processing - Multi-worker support for faster batch rendering
- CLI-first - Simple command-line interface for automation
Prerequisites
- Python 3.9 or higher
- ~300MB disk space (for Playwright browser binaries)
- Internet connection (workflows render via n8n cloud service)
Installation
1. Clone the Repository
git clone https://github.com/n8n-io/n8n-snap.git
cd n8n-snap
2. Create and Activate Virtual Environment
# Create virtual environment
python3 -m venv venv
# Activate it
source venv/bin/activate # On macOS/Linux
# or
venv\Scripts\activate # On Windows
3. Install the Package
# Install package with all dependencies (editable mode for development)
pip install -e .
Note: Use
pip install .for a regular installation, orpip install -e .for an editable/development installation where code changes are immediately reflected.
4. Install Playwright Browsers
Playwright requires browser binaries to render workflows. Install Chromium (recommended):
# Install Chromium browser (recommended - ~300MB download)
playwright install chromium
# Alternatively, install all browsers (Chromium, Firefox, WebKit)
playwright install
# Or install with system dependencies (Linux users)
playwright install --with-deps chromium
Verify installation:
playwright --version
Why Playwright? n8n-snap uses Playwright to automate headless Chromium for rendering workflows. The browser binaries are separate from the Python package and must be installed manually.
Quick Start
# Activate virtual environment
source venv/bin/activate
# Scan workflows to validate
n8n-snap scan examples/
# Generate snapshots (default: 1920×1080, light mode)
n8n-snap generate examples/ output/
# Generate in-place (images saved alongside JSON files)
n8n-snap generate examples/ --in-place
# Square format with dark mode
n8n-snap generate examples/ output/ --square --dark-mode
Usage
Commands
scan - Validate Workflows
Scan and validate workflow JSON files:
n8n-snap scan <input_folder>
# Options:
# --recursive/--no-recursive Scan subdirectories (default: true)
# -v, --verbose Enable verbose logging
generate - Generate Snapshots
Generate PNG snapshots from workflows:
n8n-snap generate <input_folder> [output_folder] [OPTIONS]
# Options:
# --width INTEGER Viewport width (default: 1920)
# --height INTEGER Viewport height (default: 1080)
# --square Use square aspect ratio (2560×2560)
# --dark-mode Enable dark theme
# --in-place Save images in same folder as source JSON files
# --timeout INTEGER Render timeout in seconds (default: 30)
# --wait-time INTEGER Wait time for iframe (default: 25)
# --port INTEGER Flask server port (default: 5000)
# --workers INTEGER Number of parallel workers (default: 1)
# -v, --verbose Enable verbose logging
# Note: output_folder is optional if --in-place is used
preview - Preview Single Workflow
Preview a single workflow:
n8n-snap preview <workflow.json> [OPTIONS]
# Options:
# --width INTEGER Viewport width (default: 1920)
# --height INTEGER Viewport height (default: 1080)
# --open Open the generated image
Examples
Light Mode (Default)
# Standard HD resolution
n8n-snap generate workflows/ output/
# Custom dimensions
n8n-snap generate workflows/ output/ --width 2560 --height 1440
Dark Mode
# Dark mode with default dimensions
n8n-snap generate workflows/ output/ --dark-mode
# Dark mode with custom size
n8n-snap generate workflows/ output/ --width 3840 --height 2160 --dark-mode
Square Format
# Square format (2560×2560 viewport = 5120×5120 output)
n8n-snap generate workflows/ output/ --square
# Square with dark mode
n8n-snap generate workflows/ output/ --square --dark-mode
Custom Aspect Ratios
# Ultra-wide (21:9)
n8n-snap generate workflows/ output/ --width 3440 --height 1440 --dark-mode
# Portrait (9:16)
n8n-snap generate workflows/ output/ --width 1080 --height 1920 --dark-mode
# 4K (16:9)
n8n-snap generate workflows/ output/ --width 3840 --height 2160 --dark-mode
Verbose Output
# Show detailed logs for debugging
n8n-snap generate workflows/ output/ --square --dark-mode --verbose
In-Place Mode
Save images directly alongside their source JSON files with automatic status tracking:
# Basic in-place mode - images saved in same folder as JSON files
n8n-snap generate workflows/ --in-place
# In-place with dark mode and square format
n8n-snap generate workflows/ --in-place --dark-mode --square
# In-place with parallel workers for faster processing
n8n-snap generate workflows/ --in-place --workers 4
What happens:
- PNG images are created in the same directory as their source JSON files
- A status report (
output.json) is generated at the root of the input folder - Works seamlessly with nested folder structures
- Existing images are automatically replaced
Example folder structure:
workflows/
├── team-a/
│ ├── workflow1.json
│ └── workflow1.png ← Generated here
├── team-b/
│ └── nested/
│ ├── workflow2.json
│ └── workflow2.png ← Generated here
└── output.json ← Status report
Status Report (output.json):
- Processing timestamps (start/end)
- Summary statistics (total, successful, failed, replaced)
- Per-workflow details (source path, output path, status, errors)
- Render settings used (dimensions, dark mode, etc.)
Parallel Processing
Process multiple workflows simultaneously for faster batch rendering:
# Use 4 parallel workers
n8n-snap generate workflows/ output/ --workers 4
# Combine with in-place mode
n8n-snap generate workflows/ --in-place --workers 4 --dark-mode
Performance notes:
- Each worker uses ~400MB memory
- Recommended: Number of CPU cores or less
- Best for large batches (10+ workflows)
Output
File Format
- Format: PNG
- Resolution: Viewport dimensions × 2 (retina quality)
- Naming:
{sanitized-filename}.png
Examples
| Viewport | Device Scale | Output Resolution |
|---|---|---|
| 1920×1080 | 2x | 3840×2160 (4K) |
| 2560×1440 | 2x | 5120×2880 (5K) |
| 2560×2560 | 2x | 5120×5120 (Square 5K) |
| 3840×2160 | 2x | 7680×4320 (8K) |
File Sizes
Typical file sizes range from 100-350 KB depending on:
- Workflow complexity
- Number of nodes
- Dimensions
How It Works
This tool uses the official @n8n/demo web component from n8n to render workflows. The component leverages n8n's cloud rendering service to visualize workflows accurately.
- Flask Server - Serves HTML page with n8n-demo web component
- n8n-demo Component - Official n8n workflow visualization component (@n8n/demo)
- Playwright Browser - Launches headless Chromium to render workflows
- Screenshot Capture - Captures iframe content at specified dimensions
- PNG Output - Saves high-quality PNG images
Note: This project is not officially affiliated with n8n. It uses the publicly available n8n-demo component for workflow rendering.
Architecture
Workflow JSON → Flask Server → n8n-demo Component
↓
Shadow DOM + iframe
↓
n8n Cloud Rendering Service
↓
Playwright Screenshot
↓
PNG Output
Workflow JSON Format
Workflows must be valid n8n workflow JSON files with:
{
"name": "Workflow Name",
"nodes": [
{
"name": "Node Name",
"type": "node-type",
"position": [x, y],
"parameters": {},
"typeVersion": 1.0
}
],
"connections": {},
"active": true
}
Troubleshooting
"No valid workflows found"
- Ensure JSON files are valid n8n workflow exports
- Check that files have
.jsonextension - Verify workflow structure with
n8n-snap scan
"Failed to render workflow"
- Check internet connection (requires n8n cloud service)
- Increase timeout:
--timeout 60 - Increase wait time:
--wait-time 30 - Run with
--verboseto see detailed logs
"Module not found" errors
- Ensure virtual environment is activated
- Reinstall dependencies:
pip install -r requirements.txt - Reinstall package:
pip install -e .
Playwright browser not found
playwright install chromium
Using with Your Own Virtual Environment
If you prefer to use your own virtual environment:
# Activate your virtualenv
source /path/to/your/venv/bin/activate
# Navigate to project
cd /Users/edmundhee/Work/GitHub/n8nspace/n8n-snap/python-n8n-snap
# Install package
pip install -e .
# Install Playwright browsers
playwright install chromium
# Use the tool
n8n-snap --help
Performance
- Processing Time: ~25 seconds per workflow (iframe rendering)
- Memory Usage: ~200-400 MB per browser instance
- Processing Mode: Sequential (single worker) or parallel (multiple workers)
- Parallel Workers: Configurable via
--workersflag (1-CPU count) - Throughput: Scales linearly with worker count for batch processing
Technical Details
Dependencies
- playwright (1.48.0) - Browser automation
- flask (3.0.0) - Web server for rendering
- click (8.1.7) - CLI framework
- rich (13.7.0) - Terminal formatting
- pydantic (2.5.0) - Data validation
Limitations
- Requires internet connection (n8n cloud rendering service)
- ~25 second minimum render time per workflow
- Light and dark themes supported (via n8n-demo component)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Third-Party Components
This project uses the following third-party components:
- @n8n/demo - Official n8n workflow visualization component (Apache 2.0 License)
- Workflow rendering is powered by n8n's cloud rendering service
Disclaimer: This project is not officially affiliated with or endorsed by n8n. It is an independent tool that uses publicly available n8n components.
Contributing
Contributions are welcome! Here's how you can help:
Getting Started
-
Fork the repository
git fork https://github.com/yourusername/n8n-snap.git
-
Create a feature branch
git checkout -b feature/your-feature-name
-
Make your changes
- Follow the existing code style
- Add tests if applicable
- Update documentation as needed
-
Test your changes
# Run the tool locally pip install -e . n8n-snap generate examples/ --in-place
-
Commit your changes
git commit -m "Add: description of your changes"
-
Push and create a Pull Request
git push origin feature/your-feature-name
Guidelines
- Code Quality: Ensure code is clean, well-commented, and follows Python best practices
- Documentation: Update README.md for any new features or changes
- Testing: Test your changes with various workflow files
- Commit Messages: Use clear, descriptive commit messages
- Issues: Feel free to open issues for bugs, features, or questions
Areas for Contribution
- 🐛 Bug fixes and improvements
- ✨ New features (e.g., additional output formats, filtering options)
- 📚 Documentation improvements
- 🧪 Test coverage
- 🎨 UI/UX improvements for CLI output
- ⚡ Performance optimizations
Version: 1.0.0 Last Updated: 2025-11-15
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 n8n_snap-1.0.0.tar.gz.
File metadata
- Download URL: n8n_snap-1.0.0.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee26627008b24f9f2202d26f5ff2bc3d5778c4a3572c2c541e5c66f248abbab4
|
|
| MD5 |
f661da725284e74b60c6a01509be9ae3
|
|
| BLAKE2b-256 |
98a0f15b50c01dd745f86aa85bd232e6bea7f5ee57374fcfeb59267419594522
|
Provenance
The following attestation bundles were made for n8n_snap-1.0.0.tar.gz:
Publisher:
publish.yml on EdmundHee/n8n-workflow-image-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
n8n_snap-1.0.0.tar.gz -
Subject digest:
ee26627008b24f9f2202d26f5ff2bc3d5778c4a3572c2c541e5c66f248abbab4 - Sigstore transparency entry: 730353026
- Sigstore integration time:
-
Permalink:
EdmundHee/n8n-workflow-image-generator@757352bddfeb9e5dee6cb23c9e0909a09f84cd42 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/EdmundHee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@757352bddfeb9e5dee6cb23c9e0909a09f84cd42 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file n8n_snap-1.0.0-py3-none-any.whl.
File metadata
- Download URL: n8n_snap-1.0.0-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b25f099ab9c539e84f64531d9f1bf1497984da5e5b71008fcb12fbe638a21d4
|
|
| MD5 |
b388089bcae3d60ecbb6414ee655b62f
|
|
| BLAKE2b-256 |
200b365118b992d2d119c6151e4167a05efd3bcd632b8bedd463662f1cca5945
|
Provenance
The following attestation bundles were made for n8n_snap-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on EdmundHee/n8n-workflow-image-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
n8n_snap-1.0.0-py3-none-any.whl -
Subject digest:
0b25f099ab9c539e84f64531d9f1bf1497984da5e5b71008fcb12fbe638a21d4 - Sigstore transparency entry: 730353028
- Sigstore integration time:
-
Permalink:
EdmundHee/n8n-workflow-image-generator@757352bddfeb9e5dee6cb23c9e0909a09f84cd42 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/EdmundHee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@757352bddfeb9e5dee6cb23c9e0909a09f84cd42 -
Trigger Event:
workflow_dispatch
-
Statement type: