Excalidraw Library Tools
This directory contains scripts for working with Excalidraw libraries.
split-excalidraw-library.py
Splits an Excalidraw library file (*.excalidrawlib) into individual icon JSON files for efficient token usage by AI assistants.
Prerequisites
- Python 3.6 or higher
- No additional dependencies required (uses only standard library)
Usage
python split-excalidraw-library.py <path-to-library-directory>
Step-by-Step Workflow
-
Create library directory:
mkdir -p skills/excalidraw-diagram-generator/libraries/aws-architecture-icons -
Download and place library file:
- Visit: https://libraries.excalidraw.com/
- Search for "AWS Architecture Icons" and download the
.excalidrawlibfile - Rename it to match the directory name:
aws-architecture-icons.excalidrawlib - Place it in the directory created in step 1
-
Run the script:
python skills/excalidraw-diagram-generator/scripts/split-excalidraw-library.py skills/excalidraw-diagram-generator/libraries/aws-architecture-icons/
Output Structure
The script creates the following structure in the library directory:
skills/excalidraw-diagram-generator/libraries/aws-architecture-icons/
aws-architecture-icons.excalidrawlib # Original file (kept)
reference.md # Generated: Quick reference table
icons/ # Generated: Individual icon files
API-Gateway.json
CloudFront.json
EC2.json
S3.json
...
What the Script Does
- Reads the
.excalidrawlibfile - Extracts each icon from the
libraryItemsarray - Sanitizes icon names to create valid filenames (spaces → hyphens, removes special characters)
- Saves each icon as a separate JSON file in the
icons/directory - Generates a
reference.mdfile with a table mapping icon names to filenames
Benefits
- Token Efficiency: AI can first read the lightweight
reference.mdto find relevant icons, then load only the specific icon files needed - Organization: Icons are organized in a clear directory structure
- Extensibility: Users can add multiple library sets side-by-side
Recommended Workflow
- Download desired Excalidraw libraries from https://libraries.excalidraw.com/
- Run this script on each library file
- Move the generated folders to
../libraries/ - The AI assistant will use
reference.mdfiles to locate and use icons efficiently
Library Sources (Examples — verify availability)
- Examples found on https://libraries.excalidraw.com/ may include cloud/service icon sets.
- Availability changes over time; verify the exact library names on the site before use.
- This script works with any valid
.excalidrawlibfile you provide.
Troubleshooting
Error: File not found
- Check that the file path is correct
- Make sure the file has a
.excalidrawlibextension
Error: Invalid library file format
- Ensure the file is a valid Excalidraw library file
- Check that it contains a
libraryItemsarray
License Considerations
When using third-party icon libraries:
- AWS Architecture Icons: Subject to AWS Content License
- GCP Icons: Subject to Google's terms
- Other libraries: Check each library's license
This script is for personal/organizational use. Redistribution of split icon files should comply with the original library's license terms.
add-icon-to-diagram.py
Adds a specific icon from a split Excalidraw library into an existing .excalidraw diagram. The script handles coordinate translation and ID collision avoidance, and can optionally add a label under the icon.
Prerequisites
- Python 3.6 or higher
- A diagram file (
.excalidraw) - A split icon library directory (created by
split-excalidraw-library.py)
Usage
python add-icon-to-diagram.py <diagram-path> <icon-name> <x> <y> [OPTIONS]
Options
--library-path PATH: Path to the icon library directory (default:aws-architecture-icons)--label TEXT: Add a text label below the icon ----use-edit-suffix: Edit via.excalidraw.editto avoid editor overwrite issues (enabled by default; pass--no-use-edit-suffixto disable)
Examples
# Add EC2 icon at position (400, 300)
python add-icon-to-diagram.py diagram.excalidraw EC2 400 300
# Add VPC icon with label
python add-icon-to-diagram.py diagram.excalidraw VPC 200 150 --label "VPC"
# Safe edit mode is enabled by default (avoids editor overwrite issues)
# Use `--no-use-edit-suffix` to disable
python add-icon-to-diagram.py diagram.excalidraw EC2 500 300
# Add icon from another library
python add-icon-to-diagram.py diagram.excalidraw Compute-Engine 500 200 \
--library-path libraries/gcp-icons --label "API Server"
What the Script Does
- Loads the icon JSON from the library’s
icons/directory - Calculates the icon’s bounding box
- Offsets all coordinates to the target position
- Generates unique IDs for all elements and groups
- Appends the transformed elements to the diagram
- (Optional) Adds a label beneath the icon
add-arrow.py
Adds a straight arrow between two points in an existing .excalidraw diagram. Supports optional labels and line styles.
Prerequisites
- Python 3.6 or higher
- A diagram file (
.excalidraw)
Usage
python add-arrow.py <diagram-path> <from-x> <from-y> <to-x> <to-y> [OPTIONS]
Options
--style {solid|dashed|dotted}: Line style (default:solid)--color HEX: Arrow color (default:#1e1e1e)--label TEXT: Add a text label on the arrow ----use-edit-suffix: Edit via.excalidraw.editto avoid editor overwrite issues (enabled by default; pass--no-use-edit-suffixto disable)
Examples
# Simple arrow
python add-arrow.py diagram.excalidraw 300 200 500 300
# Arrow with label
python add-arrow.py diagram.excalidraw 300 200 500 300 --label "HTTPS"
# Dashed arrow with custom color
python add-arrow.py diagram.excalidraw 400 350 600 400 --style dashed --color "#7950f2"
# Safe edit mode is enabled by default (avoids editor overwrite issues)
# Use `--no-use-edit-suffix` to disable
python add-arrow.py diagram.excalidraw 300 200 500 300
What the Script Does
- Creates an arrow element from the given coordinates
- (Optional) Adds a label near the arrow midpoint
- Appends elements to the diagram
- Saves the updated file