{"_id":"@swiftlysingh/excalidraw-cli","_rev":"4-ad343a29b481aca5b9c9488cd68580ab","name":"@swiftlysingh/excalidraw-cli","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@swiftlysingh/excalidraw-cli","version":"1.0.0","keywords":["excalidraw","flowchart","diagram","cli","visualization"],"author":"","license":"MIT","_id":"@swiftlysingh/excalidraw-cli@1.0.0","maintainers":[{"name":"swiftlysingh","email":"pushpinderpal19@gmail.com"}],"homepage":"https://github.com/swiftlysingh/excalidraw-cli#readme","bugs":{"url":"https://github.com/swiftlysingh/excalidraw-cli/issues"},"bin":{"excalidraw-cli":"dist/cli.js"},"dist":{"shasum":"5ac3004eb3911110b6d5b054702da9e81a371cb2","tarball":"https://registry.npmjs.org/@swiftlysingh/excalidraw-cli/-/excalidraw-cli-1.0.0.tgz","fileCount":75,"integrity":"sha512-qjrLBQ4T6iiiskjdytPd3h5Lccvt921GcqC6JkUpndakNsicdt+KsZ63lY/sZLAFuH6cbh2ST7AtIFF0pMhFZA==","signatures":[{"sig":"MEQCICs6qzYsnBqwwjgaQllcVES6mGBp9VUmFsrk7uaKrzNrAiBFWPV9HqOrG6bt0jHjOkudinWBgn8j+kwV6J/yvuqucw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":125875},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"c4c34b35ba5032884508d762e70e29397ff9e33c","scripts":{"dev":"tsc --watch","lint":"eslint src --ext .ts","test":"vitest","build":"tsc","format":"prettier --write \"src/**/*.ts\"","test:run":"vitest run","prepublishOnly":"npm run build"},"_npmUser":{"name":"swiftlysingh","email":"pushpinderpal19@gmail.com"},"repository":{"url":"git+https://github.com/swiftlysingh/excalidraw-cli.git","type":"git"},"_npmVersion":"11.6.0","description":"CLI for creating Excalidraw flowcharts programmatically","directories":{},"_nodeVersion":"24.9.0","dependencies":{"elkjs":"^0.9.3","nanoid":"^5.0.9","commander":"^12.1.0"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.17.0","vitest":"^2.1.8","prettier":"^3.4.2","typescript":"^5.7.2","@types/node":"^22.10.5","@typescript-eslint/parser":"^8.19.1","@typescript-eslint/eslint-plugin":"^8.19.1"},"_npmOperationalInternal":{"tmp":"tmp/excalidraw-cli_1.0.0_1767963304483_0.6609973840274603","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@swiftlysingh/excalidraw-cli","version":"1.0.1","keywords":["excalidraw","flowchart","diagram","cli","visualization"],"author":"","license":"MIT","_id":"@swiftlysingh/excalidraw-cli@1.0.1","maintainers":[{"name":"swiftlysingh","email":"pushpinderpal19@gmail.com"}],"homepage":"https://github.com/swiftlysingh/excalidraw-cli#readme","bugs":{"url":"https://github.com/swiftlysingh/excalidraw-cli/issues"},"bin":{"excalidraw-cli":"dist/cli.js"},"dist":{"shasum":"86ca9f33254fc27113b7e595bf81d37113c9d945","tarball":"https://registry.npmjs.org/@swiftlysingh/excalidraw-cli/-/excalidraw-cli-1.0.1.tgz","fileCount":75,"integrity":"sha512-TYt1gKiDz5hUDP781DqioQ7l2J+HlUIS0KUsICB7KhetfVl0jBR9eEXUcP+APKjTbTAyrP8uYTTiuDkbNJlFDw==","signatures":[{"sig":"MEUCIQCiJ5UguK9dKqT9EUBTe3ZoiKRabMpbBi+L24aiPvHdlwIgSe6ym7CkSFzSVt1M10XOM+VQthirrOmooLcyaBgyHBg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":126636},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"a85c0c35d930d5b1a29f9af40dd2847936b294ae","scripts":{"dev":"tsc --watch","lint":"eslint src --ext .ts","test":"vitest","build":"tsc","format":"prettier --write \"src/**/*.ts\"","test:run":"vitest run","prepublishOnly":"npm run build"},"_npmUser":{"name":"swiftlysingh","email":"pushpinderpal19@gmail.com"},"repository":{"url":"git+https://github.com/swiftlysingh/excalidraw-cli.git","type":"git"},"_npmVersion":"11.6.0","description":"CLI for creating Excalidraw flowcharts programmatically","directories":{},"_nodeVersion":"24.9.0","dependencies":{"elkjs":"^0.9.3","nanoid":"^5.0.9","commander":"^12.1.0"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.17.0","vitest":"^2.1.8","prettier":"^3.4.2","typescript":"^5.7.2","@types/node":"^22.10.5","@typescript-eslint/parser":"^8.19.1","@typescript-eslint/eslint-plugin":"^8.19.1"},"_npmOperationalInternal":{"tmp":"tmp/excalidraw-cli_1.0.1_1767980336299_0.7203521501522727","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@swiftlysingh/excalidraw-cli","version":"1.1.0","keywords":["excalidraw","flowchart","diagram","cli","visualization"],"author":"","license":"MIT","_id":"@swiftlysingh/excalidraw-cli@1.1.0","maintainers":[{"name":"swiftlysingh","email":"pushpinderpal19@gmail.com"}],"homepage":"https://github.com/swiftlysingh/excalidraw-cli#readme","bugs":{"url":"https://github.com/swiftlysingh/excalidraw-cli/issues"},"bin":{"excalidraw-cli":"dist/cli.js"},"dist":{"shasum":"10f804b3799171a7de28055ddb107206416c299b","tarball":"https://registry.npmjs.org/@swiftlysingh/excalidraw-cli/-/excalidraw-cli-1.1.0.tgz","fileCount":83,"integrity":"sha512-O5NdxMuaLmGAa6ReSkfA/lT/VmKml5eFaOJOvPb4kzEap+9nmZ93Jj3SkHmliJWFHla38PA21zStSpsYiT59TQ==","signatures":[{"sig":"MEUCICj37GjtquZm1R/9sqbp0arHaiaN+6qzr2crefrCAbD4AiEA/LnaNX8+sTUebjToVRHXgo9L/PlfQbGWAFkyg7sz+FQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":191438},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"b4670faca5c02cc35ed0dbd5fb77f3ed5d0d2d67","scripts":{"dev":"tsc --watch","lint":"eslint src --ext .ts","test":"vitest","build":"tsc","format":"prettier --write \"src/**/*.ts\"","test:run":"vitest run","prepublishOnly":"npm run build"},"_npmUser":{"name":"swiftlysingh","email":"pushpinderpal19@gmail.com"},"repository":{"url":"git+https://github.com/swiftlysingh/excalidraw-cli.git","type":"git"},"_npmVersion":"10.8.2","description":"CLI for creating Excalidraw flowcharts programmatically","directories":{},"_nodeVersion":"20.19.6","dependencies":{"elkjs":"^0.9.3","nanoid":"^5.0.9","commander":"^12.1.0","ts-graphviz":"^3.0.6"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.17.0","vitest":"^2.1.8","prettier":"^3.4.2","typescript":"^5.7.2","@types/node":"^22.10.5","@typescript-eslint/parser":"^8.19.1","@typescript-eslint/eslint-plugin":"^8.19.1"},"_npmOperationalInternal":{"tmp":"tmp/excalidraw-cli_1.1.0_1768331604402_0.7684164361559749","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@swiftlysingh/excalidraw-cli","version":"1.2.0","description":"CLI for creating Excalidraw flowcharts programmatically","type":"module","main":"dist/index.js","types":"dist/index.d.ts","bin":{"excalidraw-cli":"dist/cli.js"},"man":["man/excalidraw-cli.1"],"scripts":{"build":"tsc","dev":"tsc --watch","test":"vitest","test:run":"vitest run","lint":"eslint src --ext .ts","format":"prettier --write \"src/**/*.ts\"","prepublishOnly":"npm run build"},"keywords":["excalidraw","flowchart","diagram","cli","visualization"],"author":"","license":"MIT","repository":{"type":"git","url":"git+https://github.com/swiftlysingh/excalidraw-cli.git"},"engines":{"node":">=20.19.0"},"dependencies":{"@excalidraw/utils":"0.1.3-test32","@resvg/resvg-js":"^2.6.2","commander":"^12.1.0","elkjs":"^0.9.3","jsdom":"^28.1.0","nanoid":"^5.0.9","ts-graphviz":"^3.0.6"},"devDependencies":{"@types/jsdom":"^28.0.0","@types/node":"^22.10.5","@typescript-eslint/eslint-plugin":"^8.19.1","@typescript-eslint/parser":"^8.19.1","eslint":"^9.17.0","prettier":"^3.4.2","typescript":"^5.7.2","vitest":"^2.1.8"},"_id":"@swiftlysingh/excalidraw-cli@1.2.0","gitHead":"c171c66b3edd7bd703a395787127f32bb41b7d1a","bugs":{"url":"https://github.com/swiftlysingh/excalidraw-cli/issues"},"homepage":"https://github.com/swiftlysingh/excalidraw-cli#readme","_nodeVersion":"20.19.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-cdBYhhEwR0uLI9X8/dTpSmAvkTgmB/bLZFc8QRlP8bMz6seBaTHfYR7hJP2tyEwqQSEKd9xF0sLyPDSw8Y09Ng==","shasum":"a31471b92f439be9d2982a3062a85bdd2c8d7c0d","tarball":"https://registry.npmjs.org/@swiftlysingh/excalidraw-cli/-/excalidraw-cli-1.2.0.tgz","fileCount":96,"unpackedSize":239487,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCldSIp2ANVTk8tFtS0QJTqlaCfMTAcrX6xdw/Wc0HJ1QIhAIg5SO0H5nOteCtVR088Fr3srTTTOvvhqCSHk9Q04Rs0"}]},"_npmUser":{"name":"swiftlysingh","email":"pushpinderpal19@gmail.com"},"directories":{},"maintainers":[{"name":"swiftlysingh","email":"pushpinderpal19@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/excalidraw-cli_1.2.0_1773640424281_0.6530017902868557"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-09T12:55:04.430Z","modified":"2026-03-16T05:53:44.547Z","1.0.0":"2026-01-09T12:55:04.619Z","1.0.1":"2026-01-09T17:38:56.442Z","1.1.0":"2026-01-13T19:13:24.552Z","1.2.0":"2026-03-16T05:53:44.420Z"},"bugs":{"url":"https://github.com/swiftlysingh/excalidraw-cli/issues"},"license":"MIT","homepage":"https://github.com/swiftlysingh/excalidraw-cli#readme","keywords":["excalidraw","flowchart","diagram","cli","visualization"],"repository":{"type":"git","url":"git+https://github.com/swiftlysingh/excalidraw-cli.git"},"description":"CLI for creating Excalidraw flowcharts programmatically","maintainers":[{"name":"swiftlysingh","email":"pushpinderpal19@gmail.com"}],"readme":"# excalidraw-cli\n<p>\n  <a href=\"https://www.npmjs.com/package/@swiftlysingh/excalidraw-cli\"><img src=\"https://img.shields.io/npm/v/@swiftlysingh/excalidraw-cli\" alt=\"npm version\"></a>\n  <a href=\"https://github.com/swiftlysingh/excalidraw-cli/blob/main/LICENSE\"><img src=\"https://img.shields.io/badge/license-MIT-blue\" alt=\"MIT License\"></a>\n</p>\n\n<p align=\"center\">\n  <img alt=\"image\" src=\"https://github.com/user-attachments/assets/5af4b002-bd69-4187-8836-84135685117a\" />\n</p>\n\n<p align=\"center\">\n  Create Excalidraw flowcharts and diagrams from text-based DSL or JSON.\n</p>\n\n\n\n## Features\n\n- **Text-based DSL** for quick flowchart creation\n- **JSON API** for programmatic use\n- **Auto-layout** using ELK.js (Eclipse Layout Kernel)\n- **Multiple flow directions**: TB (top-bottom), BT, LR, RL\n- **Export to PNG & SVG** with dark mode, custom backgrounds, scale, and padding\n- **Programmable API** for integration into other tools\n\n\n## Installation\n\nRequires `Node >=20.19.0`. Node 18 is no longer supported.\n\n### Using npm\n\n```bash\nnpm i @swiftlysingh/excalidraw-cli\n```\n\n### From Source (Local Development)\n\n```bash\ngit clone https://github.com/swiftlysingh/excalidraw-cli.git\ncd excalidraw-cli\nnpm install\nnpm run build\nnpm link  # Makes 'excalidraw-cli' available globally\n```\n\n### Direct Usage (No Install)\n\n```bash\n# Run directly with node\nnode dist/cli.js create --inline \"[A] -> [B]\" -o diagram.excalidraw\n```\n\n## Quick Start\n\n### Create from DSL\n\n```bash\n# Inline DSL\nexcalidraw-cli create --inline \"(Start) -> [Process] -> {Decision?}\" -o flow.excalidraw\n\n# From file\nexcalidraw-cli create flowchart.dsl -o diagram.excalidraw\n\n# From stdin\necho \"[A] -> [B] -> [C]\" | excalidraw-cli create --stdin -o diagram.excalidraw\n```\n\n### Export to Image\n\n```bash\n# Convert an existing .excalidraw file to PNG\nexcalidraw-cli convert diagram.excalidraw --format png\n\n# Convert with options\nexcalidraw-cli convert diagram.excalidraw --format png --scale 2 --dark\n\n# Convert to SVG without background\nexcalidraw-cli convert diagram.excalidraw --format svg --no-export-background\n```\n\n### DSL Syntax\n\n| Syntax | Element | Description |\n|--------|---------|-------------|\n| `[Label]` | Rectangle | Process steps, actions |\n| `{Label}` | Diamond | Decisions, conditionals |\n| `(Label)` | Ellipse | Start/End points |\n| `[[Label]]` | Database | Data storage |\n| `->` | Arrow | Connection |\n| `-->` | Dashed Arrow | Dashed connection |\n| `-> \"text\" ->` | Labeled Arrow | Connection with label |\n\n### Example DSL\n\n```\n(Start) -> [Enter Credentials] -> {Valid?}\n{Valid?} -> \"yes\" -> [Dashboard] -> (End)\n{Valid?} -> \"no\" -> [Show Error] -> [Enter Credentials]\n```\n\n### Directives\n\n```\n@direction LR    # Left to Right (default: TB)\n@spacing 60      # Node spacing in pixels\n```\n\n## CLI Reference\n\n### Commands\n\n#### `create`\n\nCreate an Excalidraw flowchart.\n\n```bash\nexcalidraw-cli create [input] [options]\n```\n\n**Options:**\n- `-o, --output <file>` - Output file path (default: flowchart.excalidraw)\n- `-f, --format <type>` - Input format: dsl, json, dot (default: dsl)\n- `--inline <dsl>` - Inline DSL string\n- `--stdin` - Read from stdin\n- `-d, --direction <dir>` - Flow direction: TB, BT, LR, RL\n- `-s, --spacing <n>` - Node spacing in pixels\n- `--verbose` - Verbose output\n\n#### `convert`\n\nConvert an existing `.excalidraw` file to PNG or SVG.\n\n```bash\nexcalidraw-cli convert <input> [options]\n```\n\n**Options:**\n- `--format <format>` - **(required)** Export format: `png` or `svg`\n- `-o, --output <file>` - Output file path (default: input file with swapped extension)\n- `--export-background / --no-export-background` - Include or exclude background\n- `--background-color <color>` - Background color (default: #ffffff)\n- `--dark` - Export with dark mode theme\n- `--embed-scene` - Embed scene data in exported image\n- `--padding <n>` - Padding around content in pixels (default: 10)\n- `--scale <n>` - Scale factor for PNG export (default: 1)\n- `--verbose` - Verbose output\n\n#### `parse`\n\nParse and validate input without generating output.\n\n```bash\nexcalidraw-cli parse <input> [options]\n```\n\n## JSON API\n\nFor programmatic flowchart creation:\n\n```json\n{\n  \"nodes\": [\n    { \"id\": \"start\", \"type\": \"ellipse\", \"label\": \"Start\" },\n    { \"id\": \"process\", \"type\": \"rectangle\", \"label\": \"Process\" },\n    { \"id\": \"end\", \"type\": \"ellipse\", \"label\": \"End\" }\n  ],\n  \"edges\": [\n    { \"from\": \"start\", \"to\": \"process\" },\n    { \"from\": \"process\", \"to\": \"end\" }\n  ],\n  \"options\": {\n    \"direction\": \"TB\",\n    \"nodeSpacing\": 50\n  }\n}\n```\n\n```bash\nexcalidraw-cli create flowchart.json -o diagram.excalidraw\n```\n\n## Programmatic Usage\n\n```typescript\nimport {\n  createFlowchartFromDSL,\n  createFlowchartFromJSON,\n  convertToSVG,\n  convertToPNG,\n} from '@swiftlysingh/excalidraw-cli';\n\n// From DSL\nconst dsl = '(Start) -> [Process] -> (End)';\nconst json = await createFlowchartFromDSL(dsl);\n\n// From JSON input\nconst input = {\n  nodes: [\n    { id: 'a', type: 'rectangle', label: 'Hello' },\n    { id: 'b', type: 'rectangle', label: 'World' }\n  ],\n  edges: [{ from: 'a', to: 'b' }]\n};\nconst json2 = await createFlowchartFromJSON(input);\n```\n\n### Export API\n\n```typescript\nimport { convertToSVG, convertToPNG } from '@swiftlysingh/excalidraw-cli';\nimport { readFileSync, writeFileSync } from 'fs';\n\n// Load an existing .excalidraw file\nconst file = JSON.parse(readFileSync('diagram.excalidraw', 'utf-8'));\n\n// Export to SVG\nconst svg = await convertToSVG(file, { padding: 20 });\nwriteFileSync('diagram.svg', svg);\n\n// Export to PNG with 2x scale and dark mode\nconst png = await convertToPNG(file, {\n  scale: 2,\n  dark: true,\n});\nwriteFileSync('diagram.png', png);\n```\n\n`@excalidraw/utils` remains a required runtime dependency for image export. The CLI uses its `exportToSvg()` implementation for SVG generation, and reuses the bundled Excalidraw font assets so server-side PNG rendering keeps text output close to the browser version.\n\n## Examples\n\nHere are some flowcharts created with excalidraw-cli:\n\n### Simple Flow\n![Simple Flow](assets/up.png)\n\n### iOS App Architecture\n![iOS App Architecture](assets/ios-app-architecture.png)\n\n### LeetCode Problem Solving Flow\n![LeetCode Flow](assets/leetcode.png)\n\n## Output\n\nThe generated `.excalidraw` files can be:\n\n1. Opened directly in [Excalidraw](https://excalidraw.com) (File > Open)\n2. Imported into Obsidian with the Excalidraw plugin\n3. Used with any tool that supports the Excalidraw format\n\nWith the `convert` command, you can also generate:\n\n- **SVG** — scalable vector graphics, ideal for embedding in docs or web pages\n- **PNG** — raster images at any scale (1×, 2×, 3×, etc.) for presentations or sharing\n\n## License\n\nMIT\n","readmeFilename":"README.md"}