Skip to content
x-cmdPublic

About

Draw service for human and agents.

Topics

Resources

Security policy

Stars

7 stars

Watchers

0 watching

Forks

Repository files navigation

draw

English | 简体中文 | Deutsch | Español | Français | Italiano | Português | Русский | Українська | 日本語 | 한국어 | Čeština | Polski | Română | Türkçe | Tiếng Việt | ไทย | Bahasa Indonesia

JSR score OpenSSF Scorecard

X-CMD Draw is an open-source SVG chart generator: put your data and styling in a URL to create bar charts, line charts, Sankey diagrams, system architecture diagrams, mind maps, and more.

Embed charts directly in READMEs, issues, PRs, blog posts, and web pages without exporting or uploading image files. Links and SVGs retain machine-readable data and parameters: readers see the chart, while AI agents can read, modify, and regenerate it without image recognition.

Sneak peek

From performance analysis to architecture design, and from maps to schedules, the complete chart definition lives in the link. Click an image to inspect the data, adjust the styling, and regenerate it. Explore more chart examples ↗

Downloads and growth
Downloads and growth
Compression algorithm comparison
Compression: speed vs ratio
OpenCode project architecture US states · GDP per capita 2024 · thousand USD
LLM technology landscape Chemical structure

Quick start

1. Teach your agent to use draw

Give the following prompt to an agent that can read web pages. The hosted draw service requires no account registration or API key:

Read and follow https://raw.githubusercontent.com/x-cmd/draw/main/skills/x-cmd-draw/SKILL.md. From now on, whenever you write a README, issue, pull request, blog post, or chat message and need a chart, use x-cmd Draw to generate a link and embed it with image syntax instead of attaching image files.

2. Describe what you need

Tell the agent what data to use, what relationship to express, and where the chart will go:

Add an architecture diagram to the README, showing the request path from the CLI through the API to the database.

For regular use, install SKILL.md in an agent that supports local skills. For Claude Code, save it as ~/.claude/skills/draw/SKILL.md; after this one-time setup, you can describe your request directly.

Features

  • 🔗 A URL is a chart: Data and styling remain readable, comparable, version-controlled text, and the link embeds directly in Markdown and web pages.
  • 🤖 Readable by people and AI: SVG handles presentation while machine-readable data and parameters support modification and regeneration—no need to infer data from an image.
  • 📊 Broad visualization support: Create data charts, flowcharts, architecture diagrams, mind maps, maps, and schedules, or use ECharts for more complex data relationships.
  • 🖱️ Interactive editing: Open an example in the interactive editor to inspect data, adjust parameters and styles, and copy the updated chart link.
  • 🚀 Open and self-hostable: Built with TypeScript and licensed under Apache-2.0, with a hosted service, CLI, npm / JSR libraries, and Cloudflare Workers deployment.

Not using an agent? Choose your workflow

Make a quick chart: use a URL

Ideal for documentation, sharing, and ad-hoc visualization. Open the demo and interactive editor, adjust the data and styling, then copy the link—or edit the URL parameters directly:

![Share example](https://x-cmd.com/draw?type=pie&labels=A,B&values=3,2)

Your readers see a chart; you keep text that is easy to modify and review.

Generate charts in bulk or integrate them: use the CLI or a library

Ideal for updating charts in CI, generating reports in bulk, working offline, and integrating charts into applications. The CLI, libraries, and hosted service share the same parameters:

npx @x-cmd/draw --type pie --labels A,B --values 3,2 --out pie.svg

To generate SVG synchronously in code, install the library and call draw:

npm install @x-cmd/draw
import { draw } from '@x-cmd/draw';

const { svg } = draw({ type: 'pie', labels: 'A,B', values: '3,2', t: 'evil', scheme: 'dark' });

Deno users can run deno add jsr:@x-cmd/draw and import from jsr:@x-cmd/draw. The rendering core accesses neither the network nor the filesystem, making it suitable for restricted environments.

Control the endpoint and data boundary: run your own service

Ideal for a shared team endpoint, internal networks, or avoiding dependence on a public service:

git clone https://github.com/x-cmd/draw && cd draw && npm install
npm run serve           # Local service: http://localhost:8787/draw
bash scripts/setup.sh   # One-command deployment to your Cloudflare account

Configure DATA_REPO, DATA_BRANCH, and GITHUB_TOKEN to enable permanent short links; regular GET rendering works without them. See the self-hosting guide.

Documentation and API

Complete chart references, parameters, and examples are organized by topic:

Topic Documentation
Browse all chart types and scenarios Documentation index · Reference charts · Cloud architecture examples
Common parameters and URL encoding Parameters
JSON data Data formats and API
Create short links or configure their storage Self-hosting and short-link configuration
Architecture, sequence, ERD, and other structural diagrams Diagram URL grammar
Run locally or deploy to Cloudflare Self-hosting guide
Generate charts with an AI agent Agent skill
Inside draw: generated project diagrams

Inside draw — the code structure

One edge worker, one render core, four directories that matter: specs/ parses, styles/ skins, render/ draws, store.ts keeps the short links.

https://x-cmd.com/draw/arch2?n=entry;fe;Worker%20entry;src/index.ts;r0c0&n=node;svc;Node%20server%20%2B%20CLI;src/node/;r0c1&n=handler;be;handler.ts;routing%20%2B%20responses;r1c0&n=demo;fe;demo/;gallery%20%2B%20landing;r1c1&n=specs;be;specs/;parse%20%2B%20validate;r2c0&n=store;db;store.ts;short%20links%20in%20a%20Git%20repo;r2c1&n=render;be;render/;draw%20the%20SVG;r3c0&n=styles;be;styles/;skins%20%2B%20families;r3c1&e=entry;handler&e=node;handler&e=handler;specs&e=handler;store&e=handler;demo&e=handler;render&e=render;styles&b=Edge%20worker;handler%20specs%20store%20render%20styles&title=Inside%20draw

draw 的代码结构

One request, step by step

The URL is parsed, a skin is picked, the SVG is drawn, and it comes back with <metadata> inside — one path for every chart type.

https://x-cmd.com/draw/seq?n=app;fe;Your%20app;;r0c0&n=worker;be;Worker;;r0c1&n=specs;be;specs/;parse%20%2B%20validate;r0c2&n=render;be;render/;draw%20the%20SVG;r0c3&e=app;worker;GET%20/draw%3Ftype=pie&e=worker;specs;parse%20the%20spec&e=specs;worker;spec;dash&e=worker;render;draw&e=render;worker;SVG;dash&e=worker;app;200%20%2B%20%3Cmetadata%3E;dash&title=One%20request

一次请求的时序

What draw is for

Four kinds of callers: your code, an AI agent, your README, and whoever runs their own copy.

https://x-cmd.com/draw/uc?n=caller;actor;Your%20app%20or%20CI&n=agent;actor;AI%20agent&n=writer;actor;README%20or%20docs&n=ops;actor;Self-host%20operator&n=uc1;uc;Render%20a%20chart;GET%20/draw%3Ftype=...&n=uc2;uc;Store%20a%20short%20link;POST%20/draw&n=uc3;uc;Embed%20the%20SVG;markdown%20%2B%20img&n=uc4;uc;Run%20it%20yourself;npm%20%2B%20wrangler&e=caller;uc1&e=caller;uc2&e=agent;uc1&e=writer;uc3&e=ops;uc4&b=draw;uc1%20uc2%20uc3%20uc4&title=What%20draw%20is%20for

draw 的用户用例

Development

npm install
npm run dev      # Start wrangler dev locally
npm test         # Vitest
npm run check    # tsc --noEmit × 3 (worker / node / build)
npm run build    # Build dist/ (npm library + CLI)
npm run deploy   # wrangler deploy

License

Code is licensed under Apache-2.0. Bundled fonts retain their own licenses: Inter (OFL, see inter-OFL.txt) and Handlee (OFL, see handlee-OFL.txt).

About

Draw service for human and agents.

Topics

Resources

Security policy

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages