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

excalidraw2png

v0.1.0

Published

CLI tool to validate and convert .excalidraw files to PNG

Downloads

14

Readme

excalidraw2png

CLI tool to validate and convert .excalidraw files to PNG. Designed for AI agent workflows — generate .excalidraw JSON, validate it, convert to PNG.

Quick Start

# No installation needed (recommended)
npx excalidraw2png validate diagram.excalidraw
npx excalidraw2png convert diagram.excalidraw -o output.png

Or install globally:

npm install -g excalidraw2png
excalidraw2png validate diagram.excalidraw
excalidraw2png convert diagram.excalidraw -o output.png

Commands

validate

Check .excalidraw file format. Returns structured errors with fix suggestions.

npx excalidraw2png validate diagram.excalidraw

# JSON output (for programmatic use)
npx excalidraw2png validate diagram.excalidraw --json

Exit code: 0 = valid, 1 = has errors.

Three validation layers:

| Layer | Scope | Severity | |-------|-------|----------| | L1 | File structure (type, elements, appState, files) | Fatal — blocks convert | | L2 | Element fields (required fields, type enums, numeric ranges) | Error — element may render wrong | | L3 | Reference integrity (boundElements, containerId, arrow bindings) | Warning — non-blocking |

Error format (designed for AI agents):

ERROR [L2] $.elements[3].strokeStyle (rectangle): got "wavy", expected ["solid","dashed","dotted"]. Fix: change strokeStyle to one of: solid, dashed, dotted

JSON output (--json) returns:

{
  "valid": false,
  "errors": [
    {
      "level": "L2",
      "path": "$.elements[3].strokeStyle",
      "elementId": "abc123",
      "elementType": "rectangle",
      "field": "strokeStyle",
      "got": "wavy",
      "expected": ["solid", "dashed", "dotted"],
      "fix": "change strokeStyle to one of: solid, dashed, dotted"
    }
  ],
  "warnings": [],
  "summary": {
    "totalElements": 5,
    "validElements": 4,
    "errorCount": 1,
    "warningCount": 0
  }
}

convert

Render .excalidraw file to PNG.

npx excalidraw2png convert diagram.excalidraw -o output.png

# Options
npx excalidraw2png convert diagram.excalidraw -o output.png --scale 2
npx excalidraw2png convert diagram.excalidraw -o output.png --no-background
npx excalidraw2png convert diagram.excalidraw -o output.png --padding 20

| Option | Default | Description | |--------|---------|-------------| | -o, --output <path> | (required) | Output PNG file path | | --scale <n> | 1 | Export scale factor (2 = retina) | | --no-background | false | Transparent background | | --padding <n> | 10 | Padding around content in pixels |

Convert runs validation first. L1 errors block conversion, L2 errors print warnings but proceed.

Supported Elements

| Element | Status | |---------|--------| | rectangle | Supported (with roundness) | | ellipse | Supported | | diamond | Supported | | text | Supported (3 font families, multi-line, alignment) | | arrow | Supported (arrowheads, bindings) | | line | Supported | | freedraw | Not yet | | image | Not yet | | frame | Not yet |

Rendering Details

  • Uses RoughJS for hand-drawn style rendering (same as Excalidraw)
  • Same seed value produces identical strokes
  • Fill styles: solid, hachure, cross-hatch, zigzag
  • Stroke styles: solid, dashed, dotted
  • Font families: Virgil (hand-drawn), Helvetica (sans-serif), Cascadia (monospace)

For AI Agents

Typical workflow:

1. Generate .excalidraw JSON
2. npx excalidraw2png validate file.excalidraw --json
3. If errors → read "fix" field → correct JSON → re-validate
4. npx excalidraw2png convert file.excalidraw -o output.png

Minimal valid .excalidraw file:

{
  "type": "excalidraw",
  "version": 2,
  "source": "agent",
  "elements": [
    {
      "type": "rectangle",
      "id": "r1",
      "x": 0, "y": 0, "width": 200, "height": 100,
      "angle": 0,
      "strokeColor": "#1e1e1e",
      "backgroundColor": "transparent",
      "fillStyle": "solid",
      "strokeWidth": 2,
      "strokeStyle": "solid",
      "roughness": 1,
      "opacity": 100,
      "seed": 1,
      "version": 1,
      "versionNonce": 1,
      "isDeleted": false,
      "groupIds": [],
      "boundElements": null,
      "link": null,
      "locked": false,
      "roundness": null
    }
  ],
  "appState": { "viewBackgroundColor": "#ffffff" },
  "files": {}
}

Requirements

  • Node.js >= 18
  • The canvas npm package requires system-level Cairo. On most systems this is handled automatically. If you get build errors, see node-canvas prerequisites.

License

MIT