npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@trohde/excal-cli

v1.0.2

Published

Agent-first CLI for Excalidraw scene inspection, validation, and rendering

Readme

excal

version npm license

Agent-first CLI for Excalidraw scene inspection, validation, and rendering.

Built for AI agents, CI pipelines, and developers who need deterministic, non-interactive workflows around .excalidraw files. Every command returns a structured JSON envelope on stdout with stable error codes and exit semantics.

Install

npm install -g @trohde/excal-cli

Or run directly with npx:

npx @trohde/excal-cli inspect diagram.excalidraw

PNG and PDF export require Playwright (optional):

npx playwright install chromium

From source

git clone https://github.com/ThomasRohde/excalidraw-cli.git
cd excalidraw-cli
npm install
npm run build

Quick Start

# Inspect a scene
excal inspect diagram.excalidraw

# Validate structure
excal validate diagram.excalidraw --check-assets

# Export to SVG
excal render diagram.excalidraw --outDir ./out

# Export to PNG + PDF
excal render diagram.excalidraw --outDir ./out --png --pdf

# Pipe from stdin
cat diagram.excalidraw | excal inspect -

# Agent bootstrapping
excal guide
excal skill

Commands

excal inspect <file|->

Return element counts, type breakdown, frame details, text stats, bounding box, image info, and binary file metadata.

excal inspect diagram.excalidraw
excal inspect diagram.excalidraw --frame "Login Flow"
excal inspect diagram.excalidraw --include-deleted

| Flag | Description | |------|-------------| | --include-deleted | Include soft-deleted elements | | --frame <id\|name> | Filter to a specific frame by ID or name |

excal validate <file|->

Check structural consistency: frame references, bound text bindings, arrow bindings, and optionally image asset references.

excal validate diagram.excalidraw
excal validate diagram.excalidraw --check-assets

| Flag | Description | |------|-------------| | --check-assets | Verify image elements reference existing binary files |

excal render <file|->

Render a scene to SVG, PNG, or PDF. SVG is the default. PNG and PDF require Playwright.

excal render diagram.excalidraw --outDir ./out
excal render diagram.excalidraw --outDir ./out --svg --png
excal render diagram.excalidraw --outDir ./out --frame "Dashboard" --dark-mode
excal render diagram.excalidraw --dry-run

| Flag | Description | |------|-------------| | --outDir <dir> | Output directory (default: .) | | --svg | Export SVG (default if no format specified) | | --png | Export PNG (requires Playwright) | | --pdf | Export PDF (requires Playwright) | | --dark-mode | Dark theme | | --no-background | Transparent background | | --scale <n> | PNG scale factor (default: 2) | | --padding <n> | Padding in pixels (default: 20) | | --frame <id\|name> | Export a specific frame only | | --element <id> | Export a specific element only | | --dry-run | Run the full pipeline but write no files |

excal guide

Print a Markdown CLI reference — commands, flags, error codes, envelope schema. Designed for agent bootstrapping.

excal skill

Print Markdown domain knowledge about Excalidraw scene structure, element types, frames, arrows, bound text, images, and export tips.

Response Envelope

Every command writes a JSON envelope to stdout:

{
  "schema_version": "1.0",
  "request_id": "req_20260302_143000_7f3a",
  "ok": true,
  "command": "scene.inspect",
  "target": { "file": "diagram.excalidraw", "fingerprint": "ab12..." },
  "result": { ... },
  "warnings": [],
  "errors": [],
  "metrics": { "duration_ms": 42 }
}
  • ok, result, warnings, errors, and metrics are always present.
  • On failure, result is null and errors contains structured error objects.
  • Each error has code, message, retryable, and suggested_action.

Error Codes

| Code | Exit | Description | |------|------|-------------| | ERR_VALIDATION_INVALID_JSON | 10 | Input is not valid JSON | | ERR_VALIDATION_INVALID_SCENE | 10 | Scene structure validation failed | | ERR_VALIDATION_UNKNOWN_FORMAT | 10 | Unrecognized input format | | ERR_RENDER_BROWSER_UNAVAILABLE | 20 | Playwright is not installed | | ERR_RENDER_EXPORT_FAILED | 20 | Browser-side export failed | | ERR_IO_READ_FAILED | 50 | Could not read input file | | ERR_IO_WRITE_FAILED | 50 | Could not write output file | | ERR_INTERNAL_UNEXPECTED | 90 | Unexpected internal error |

Input Formats

The CLI auto-detects three input formats:

  • Full scene — standard .excalidraw JSON with elements, appState, files
  • Elements-only — a bare JSON array of elements
  • Clipboard{ "type": "excalidraw/clipboard", "elements": [...] }

Architecture

src/
  cli/          Commander commands (inspect, validate, render, guide, skill)
  core/         Envelope, errors, IO, fingerprinting, exit codes
  scene/        Zod schemas, scene loading, normalization, inspection, validation, filtering
  render/       Playwright browser bridge using @excalidraw/utils
  guide/        Guide + skill markdown content

Dual bundle via tsup:

  • CLI entry — ESM, Node.js, Playwright external
  • Bridge entry — IIFE, browser, @excalidraw/utils bundled in

Rendering works by loading a minimal HTML page in headless Chromium, passing scene JSON via page.evaluate(), and calling exportToSvg/exportToBlob from @excalidraw/utils.

Development

npm run build       # Build CLI + bridge bundles
npm test            # Run all tests
npm run dev         # Watch mode build
npm run typecheck   # TypeScript type checking

Releasing

pnpm run bump:patch                              # or bump:minor / bump:major
git add -A && git commit -m "chore: release vX.Y.Z"
git push
npm publish --access=public --auth-type=web      # opens browser for npm auth

License

MIT