
Eraser Diagrams is an open-source diagramming system for creating clear, consistent, beautiful diagrams that you'd be proud to put in front of your customers, colleagues, or board. Created with ❤️ by Eraser
It is designed to be maximally useful for LLMs/agents and for maximum portability.
Use Eraser Diagrams when you want:
To create your first diagram, see Getting Started. The rest of this README explains the principles behind the system, the tradeoff it makes, and how its parts fit together.
The rapid improvement of LLMs has made it clear that hand-drawing diagrams is a thing of the past. Less clear is how to create a framework to best leverage these capabilities. We went to the drawing board and started from square one.
As they say, a picture is worth a thousand words, and a good diagram is just as valuable. But how are diagrams able to condense information so effectively?
Familiar as can be: Property names, technologies, and concepts should be self-documenting or extremely familiar by analogy with prior art. We want to teach as little as possible.
Batteries included: Diagrams want icons. Lines need routing. Users want PNGs. All of this should work without needing to write additional code and with as few dependencies or requirements as possible.
Run anywhere: Freed from needing to draw diagrams by hand, we'll be wanting to create them everywhere. It should be possible to run in as many environments as possible to enable CI jobs, slackbots, internal tools and more.
Customizable from the ground up: If you only want to allow certain colors, that should be possible. If you want to bundle visual settings into a few variants the LLM can pick from, that should be possible. Have a font or icons you like? Great. Your brand, your diagram, your stories.
Separate the diagram from the visual system: What makes a diagram specific is the data, process, or system it communicates. How to draw a node should not be learned on every request. Variants, components, schemas, and color palettes should not be decided on a diagram-by-diagram basis. This makes each individual diagram concise for LLMs to express while enforcing style guides by construction, not by prompt engineering.
Offer progressive control: In the basic case, declaring "connect A to B", using automatic dimensions, and specifying few or no visual properties should suffice to generate a simple, reasonable diagram. But leveraging the continued growth of LLMs requires exposing all of the primitives. Line routing, custom visuals, deliberately overlapping geometries - all must be possible. The expressive ceiling should not be designed around the limitations of weaker models.
Resolve authored intent into measured reality. Authored geometry and rendered geometry are different concepts. Components, fonts, wrapping, padding, and borders affect physical bounds. Routing and finalized images should account for the actual dimensions, not just an LLM's initial guess.
Produce data, not just pixels. Applications and LLMs may want to manipulate, introspect, validate, save, or update the resolved outputs before, after, or in addition to displaying the visual output.
Support extension. Today, our goal is to allow users to create the same diagrams they might in a dedicated tool like Visio or LucidChart. But as LLMs progress, it will unlock new possibilities. Our system should build on foundations that support interactivity, animations, navigation, and more.
To achieve those features, we decided on the following approach:
tag. Each tag should map to one component: a schema plus its markup and CSS. The schema defines the shape of the expected data, the component defines the visual output.We believe that the following primitives and concepts are important enough in diagrams to provide explicit first-class recognition and support:
"user" or "aws-s3", not a fully formed SVG.There are other approaches we could have taken, and that you might take if tasked with building a diagramming tool from scratch. None of the alternatives below are bad technologies. Eraser Diagrams itself is built heavily on existing web standards. The question is which layer should own diagram semantics, visual consistency, and final composition.
HTML and SVG are expressive, portable, and deeply familiar to LLMs. They are excellent choices when the desired result is one bespoke rendered artifact.
But if every request contains the complete HTML or SVG representation, the author repeatedly owns decisions that should often remain stable: component structure, typography, spacing, icon placement, variants, routing conventions, and organizational styling.
Because core diagramming concepts like connections and containment aren't cleanly modeled, edits that might be conceptually simple also need to be handled very explicitly and verbosely.
You can solve this by writing some code to fill in defaults and providing explicit instructions to an LLM.
Formats such as draw.io XML have rich diagram models and mature graphical editors. They understand nodes, connections, groups, routing, and many other diagramming concepts. If the desired output is specifically an editable document for that editor, using frontier LLMs to produce that output directly is probably the best bet.
However, these formats were designed to be an internal implementation detail, not a concise layer for LLMs. This means they are relatively expensive to generate, are more likely to be error prone, and cannot easily be manipulated by less capable LLMs.
DSLs such as Mermaid, D2, or earlier-generation Eraser DSL optimize for semantic concision. They are inexpensive in tokens, easy to read and version, and can produce relatively large diagrams very quickly.
In exchange, the renderer owns more of the final composition. The author describes the graph and can, to some extent, influence layout, but generally does not control exact placement, dimensions, attachment points, routing, or arbitrary visual structure. That is an excellent tradeoff when semantic correctness matters more than exact visual composition, but an unacceptable tradeoff if the goal is to replace handmade professionally polished diagrams.
Eraser Diagrams ships as a complete system, and we recommend using the @eraserlabs/diagrams Node API or the @eraserlabs/diagrams-cli command line.
For those curious to dig deeper, under the hood, our framework is split into several modular libraries and an implementation-agnostic model diagramming protocol that defines the basic concepts and contracts.
| Package | Responsibility |
|---|---|
@eraserlabs/diagrams | Supplies the stock Eraser profile and orchestrates resolution, Chromium, fonts, icons, rendering, HTML output, and image snapshots through the Node API. |
@eraserlabs/diagrams-cli | The eraser-diagrams command: argument parsing, eraser-diagrams.config.json, batch rendering and reporting on top of @eraserlabs/diagrams. |
@eraserlabs/resolve | Validates diagram data and profile definitions, resolves icons and other references, normalizes content, and prepares trusted renderer input. |
@eraserlabs/render | Implements the HTML template fill, authoritative browser measurement, layout, and apply pipeline. See the render contract. |
@eraserlabs/layout | Provides geometry and obstacle-aware orthogonal connection routing, including nested and partial routing; depends only on @eraserlabs/utils. |
@eraserlabs/protocol | The dependency-free reference distribution of MDP contracts, schema annotations, and machine-readable schemas. See the MDP specification. |
@eraserlabs/utils | Dependency-free helpers shared across the Eraser packages: phase timing, set helpers, and small type guards. |
Generated diagrams remain structured and editable throughout the pipeline. AI generation should be the beginning of the interaction, not the end: people and applications can move, resize, restyle, reconnect, and refine a diagram without abandoning its underlying model.
For installation and practical usage, continue to Getting Started.
1 commits
TypeScript
94.2%
CSS
3.3%
HTML
1.4%

Eraser Diagrams is an open-source diagramming system for creating clear, consistent, beautiful diagrams that you'd be proud to put in front of your customers, colleagues, or board. Created with ❤️ by Eraser
It is designed to be maximally useful for LLMs/agents and for maximum portability.
Use Eraser Diagrams when you want:
To create your first diagram, see Getting Started. The rest of this README explains the principles behind the system, the tradeoff it makes, and how its parts fit together.
The rapid improvement of LLMs has made it clear that hand-drawing diagrams is a thing of the past. Less clear is how to create a framework to best leverage these capabilities. We went to the drawing board and started from square one.
As they say, a picture is worth a thousand words, and a good diagram is just as valuable. But how are diagrams able to condense information so effectively?
Familiar as can be: Property names, technologies, and concepts should be self-documenting or extremely familiar by analogy with prior art. We want to teach as little as possible.
Batteries included: Diagrams want icons. Lines need routing. Users want PNGs. All of this should work without needing to write additional code and with as few dependencies or requirements as possible.
Run anywhere: Freed from needing to draw diagrams by hand, we'll be wanting to create them everywhere. It should be possible to run in as many environments as possible to enable CI jobs, slackbots, internal tools and more.
Customizable from the ground up: If you only want to allow certain colors, that should be possible. If you want to bundle visual settings into a few variants the LLM can pick from, that should be possible. Have a font or icons you like? Great. Your brand, your diagram, your stories.
Separate the diagram from the visual system: What makes a diagram specific is the data, process, or system it communicates. How to draw a node should not be learned on every request. Variants, components, schemas, and color palettes should not be decided on a diagram-by-diagram basis. This makes each individual diagram concise for LLMs to express while enforcing style guides by construction, not by prompt engineering.
Offer progressive control: In the basic case, declaring "connect A to B", using automatic dimensions, and specifying few or no visual properties should suffice to generate a simple, reasonable diagram. But leveraging the continued growth of LLMs requires exposing all of the primitives. Line routing, custom visuals, deliberately overlapping geometries - all must be possible. The expressive ceiling should not be designed around the limitations of weaker models.
Resolve authored intent into measured reality. Authored geometry and rendered geometry are different concepts. Components, fonts, wrapping, padding, and borders affect physical bounds. Routing and finalized images should account for the actual dimensions, not just an LLM's initial guess.
Produce data, not just pixels. Applications and LLMs may want to manipulate, introspect, validate, save, or update the resolved outputs before, after, or in addition to displaying the visual output.
Support extension. Today, our goal is to allow users to create the same diagrams they might in a dedicated tool like Visio or LucidChart. But as LLMs progress, it will unlock new possibilities. Our system should build on foundations that support interactivity, animations, navigation, and more.
To achieve those features, we decided on the following approach:
tag. Each tag should map to one component: a schema plus its markup and CSS. The schema defines the shape of the expected data, the component defines the visual output.We believe that the following primitives and concepts are important enough in diagrams to provide explicit first-class recognition and support:
"user" or "aws-s3", not a fully formed SVG.There are other approaches we could have taken, and that you might take if tasked with building a diagramming tool from scratch. None of the alternatives below are bad technologies. Eraser Diagrams itself is built heavily on existing web standards. The question is which layer should own diagram semantics, visual consistency, and final composition.
HTML and SVG are expressive, portable, and deeply familiar to LLMs. They are excellent choices when the desired result is one bespoke rendered artifact.
But if every request contains the complete HTML or SVG representation, the author repeatedly owns decisions that should often remain stable: component structure, typography, spacing, icon placement, variants, routing conventions, and organizational styling.
Because core diagramming concepts like connections and containment aren't cleanly modeled, edits that might be conceptually simple also need to be handled very explicitly and verbosely.
You can solve this by writing some code to fill in defaults and providing explicit instructions to an LLM.
Formats such as draw.io XML have rich diagram models and mature graphical editors. They understand nodes, connections, groups, routing, and many other diagramming concepts. If the desired output is specifically an editable document for that editor, using frontier LLMs to produce that output directly is probably the best bet.
However, these formats were designed to be an internal implementation detail, not a concise layer for LLMs. This means they are relatively expensive to generate, are more likely to be error prone, and cannot easily be manipulated by less capable LLMs.
DSLs such as Mermaid, D2, or earlier-generation Eraser DSL optimize for semantic concision. They are inexpensive in tokens, easy to read and version, and can produce relatively large diagrams very quickly.
In exchange, the renderer owns more of the final composition. The author describes the graph and can, to some extent, influence layout, but generally does not control exact placement, dimensions, attachment points, routing, or arbitrary visual structure. That is an excellent tradeoff when semantic correctness matters more than exact visual composition, but an unacceptable tradeoff if the goal is to replace handmade professionally polished diagrams.
Eraser Diagrams ships as a complete system, and we recommend using the @eraserlabs/diagrams Node API or the @eraserlabs/diagrams-cli command line.
For those curious to dig deeper, under the hood, our framework is split into several modular libraries and an implementation-agnostic model diagramming protocol that defines the basic concepts and contracts.
| Package | Responsibility |
|---|---|
@eraserlabs/diagrams | Supplies the stock Eraser profile and orchestrates resolution, Chromium, fonts, icons, rendering, HTML output, and image snapshots through the Node API. |
@eraserlabs/diagrams-cli | The eraser-diagrams command: argument parsing, eraser-diagrams.config.json, batch rendering and reporting on top of @eraserlabs/diagrams. |
@eraserlabs/resolve | Validates diagram data and profile definitions, resolves icons and other references, normalizes content, and prepares trusted renderer input. |
@eraserlabs/render | Implements the HTML template fill, authoritative browser measurement, layout, and apply pipeline. See the render contract. |
@eraserlabs/layout | Provides geometry and obstacle-aware orthogonal connection routing, including nested and partial routing; depends only on @eraserlabs/utils. |
@eraserlabs/protocol | The dependency-free reference distribution of MDP contracts, schema annotations, and machine-readable schemas. See the MDP specification. |
@eraserlabs/utils | Dependency-free helpers shared across the Eraser packages: phase timing, set helpers, and small type guards. |
Generated diagrams remain structured and editable throughout the pipeline. AI generation should be the beginning of the interaction, not the end: people and applications can move, resize, restyle, reconnect, and refine a diagram without abandoning its underlying model.
For installation and practical usage, continue to Getting Started.
1 commits
TypeScript
94.2%
CSS
3.3%
HTML
1.4%