Eraser DSL → Diagram

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

This endpoint creates a diagram from user-provided Eraser DSL (diagram-as-code).

Note: This endpoint does not use AI, it simply generates a diagram from the Eraser DSL (diagram-as-code) provided by the user. To learn more about the Eraser DSL, see our docs. If you are looking for the AI diagram endpoint, see here .

The diagram code must be placed in the code field of each element, with all line breaks and special characters properly escaped. The simplest way to prepare your Eraser DSL code is to open your browser's JavaScript console and run JSON.stringify(YOUR-ERASER-DSL).replaceAll('\\n', '\n'), then use the escaped output in your request.

curl --location 'https://app.eraser.io/api/render/elements' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
    "theme": "dark",
    "background": true,
    "elements": [
        {
            "type": "diagram",
            "diagramType": "sequence-diagram",
            "code": "Client [icon: monitor, color: gray]\nServer [icon: server, color: blue]\nService [icon: tool, color: green]\n\nClient > Server: Data request\nactivate Server\nServer <> Service: Service request\n\nloop [label: until success, color: green] {\n  Service > Service: Check availability\n}\n\nServer - Service: Data processing\nServer --> Client: Data response\ndeactivate Server"
        }
    ]
}'

To render a freeform diagram, set diagramType to freeform-diagram and pass a freeformElements array instead of code:

curl --location 'https://app.eraser.io/api/render/elements' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
    "theme": "dark",
    "elements": [
        {
            "type": "diagram",
            "diagramType": "freeform-diagram",
            "freeformElements": [
                { "id": "a", "tag": "Shape", "x": 0, "y": 0, "texts": [{ "text": "User Service" }] },
                { "id": "b", "tag": "Shape", "x": 300, "y": 0, "texts": [{ "text": "Payment Service" }] },
                { "id": "r1", "tag": "Relationship", "from": "a", "to": "b", "label": "calls" }
            ]
        }
    ]
}'

An example response is:

{
    "imageUrl": "https://IMAGE-SITE-URL/IMAGE-NAME.png",
    "createEraserFileUrl": "https://ERASER-URL-TO-OPEN-DIAGRAM-IN-EDITOR"
}

Full documentation of the endpoint below:

Body Params
elements
array of objects
required

Eraser canvas element objects

elements*
boolean

Select transparent (false) or solid (true) background. Defaults to false.

string
enum

Select "light" or "dark" theme. Defaults to "light".

Allowed:
integer
enum

Image quality/resolution multiplier. Use 1 (low), 2 (medium), or 3 (high). Defaults to 2.

Allowed:
integer
enum
deprecated

Deprecated. Use imageQuality instead.

Allowed:
boolean

When true, returns the image as a file stream instead of a URL.

boolean
deprecated

Deprecated. Use returnImageAsFile instead.

fileOptions
object

Options for creating an Eraser file immediately with granular link access settings, rather than returning a URL for manual creation.

string

Title for the created Eraser file. Only applies when fileOptions.create is true. If not provided, title is derived from the diagram code.

Responses

400

The request is missing the 'elements' parameter or validation failed

403

Unauthorized

500

Eraser was unable to generate a result

503

Service temporarily unavailable. This may be the result of too many requests.

Language
Credentials
Bearer
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json