diagrammer
Turn a JSON spec into a clean, blueprint-style SVG diagram. Designed so an LLM can write the spec from a plain-English description — describe → JSON → SVG → drop into post.
No dependencies. Stdlib only. Python 3.8+.
Install
pip install -e .
30-second example
echo '{
"nodes": [
{"id": "x", "type": "box", "label": "input"},
{"id": "h1", "type": "circle", "label": "h1"},
{"id": "h2", "type": "circle", "label": "h2"},
{"id": "y", "type": "box", "label": "output"}
],
"edges": [
{"from": "x", "to": "h1"}, {"from": "x", "to": "h2"},
{"from": "h1", "to": "y"}, {"from": "h2", "to": "y"}
]
}' | diagrammer - > mlp.svg && open mlp.svg
Or from a file: diagrammer examples/mlp.json > out.svg.
Spec reference
Top-level keys:
nodes(required) — list of nodes, each withid,type, optionallabel.edges(required) — list of edges, each withfrom,to, optionallabel,style("dashed"/"solid"),weight("thin"/"thick").direction—"LR"(default) or"TB".router—"straight"(default) or"ortho"for right-angle bends.col_gap,row_gap,margin— layout tuning.defs— raw SVG defs string injected into<defs>(markers, gradients, filters).
Built-in node types: box, circle, text, database, stack (param: count), note, group (param: children: [nodeIds]), custom (params: svg, w, h).
Auto-layout fills in any missing x/y/w/h. Don't hand-place nodes unless you need to.
LLM workflow
prompt.md (printable via diagrammer prompt) is a one-page doc you can paste into Claude/GPT to teach the spec format. The intended loop:
# in a chat with an LLM, paste prompt.md, then ask:
# "draw a 3-layer MLP with a softmax head"
# copy the JSON it returns, then:
pbpaste | diagrammer - > mlp.svg && open mlp.svg
Custom components
When no built-in shape fits, use type: "custom" and supply raw SVG anchored at (0,0):
{
"id": "tri", "type": "custom", "w": 80, "h": 80, "label": "split",
"svg": "<polygon points='40,5 75,75 5,75' fill='none' stroke='black' stroke-width='1.5'/>"
}
The renderer wraps your SVG in <g transform="translate(x,y)"> and uses w/h for arrow termination. For shared defs (gradients, custom markers), put them in the spec-level "defs" string and reference by id.
For Python-side extension, register_component(name, render_fn, default_w, default_h) lets you add new types without modifying the package. See test_registry.py.
Tests
python -m unittest discover tests
Refresh snapshots after intentional visual changes:
UPDATE_SNAPSHOTS=1 python -m unittest discover tests
Metadata
Release files for diagrammer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diagrammer-0.1.0.tar.gz | 12.4 kB | Without provenance | Details for diagrammer-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diagrammer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for diagrammer-0.1.0-py3-none-any.whl |
Total release size: 23.3 kB
Release files / diagrammer-0.1.0.tar.gz
| Download URL | diagrammer-0.1.0.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5d9b7cfe349b8f67cdfdea0b3ae2d57f142f297110bc6898704ba1dfbb634b6
|
|
BLAKE2b-256 checksum How to use checksums |
3981412650ae2929389d773097cdc2251c899836f60f28be2bbe13f13e306c6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / diagrammer-0.1.0-py3-none-any.whl
| Download URL | diagrammer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d048fccc422ad54f59c15f001e93965e4aa25041e52854314a015e79d7a73410
|
|
BLAKE2b-256 checksum How to use checksums |
a8dd3606d40423aed6ac700217607ad0c0359a57d7863cabfe19d6c4e06e23a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for diagrammer 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.