Docs & Code Guide

Embed a diagram in ReadMe.com docs: image by URL, embed blocks, and the OpenAPI pages

ReadMe's docs format has lived three lives: classic markdown, the JSON magic blocks of the old editor, and the MDX-based flavor of ReadMe Refactored. The good news for a diagram embed is that all three render an image by external URL, and the embed block covers the interactive case. The part that needs actual thought is the split between hand-written guides and API reference pages generated from your OpenAPI spec.

6 min readFor teams hosting developer hubs on ReadMe.com

See it as a diagram

Everything below, as a diagram you can edit. Describe yours and see it in seconds.

178/20003 credits left
Try:

No account needed · Editable canvas, not a picture

ReadMe's markdown flavor and where blocks fit

ReadMe renders its own markdown flavor, and pages written in the old editor may still contain magic blocks: JSON payloads between [block:...] and [/block] markers that describe rich components. ReadMe Refactored moved the format to MDX, and its processor transpiles the legacy block JSON for backwards compatibility, so both syntaxes keep rendering.

For a diagram, the practical takeaway is that a plain markdown image with an external URL works in every generation of the format, and pointed at a live endpoint it keeps the page current without edits: the image re-renders when the diagram changes, with a five minute cache lifetime.

![Platform architecture](https://datadef.io/api/embed/my-platform-a1b2c3d4)

<!-- Legacy magic block form, still rendered for older pages: -->
[block:embed]
{
  "url": "https://datadef.io/embed/my-platform-a1b2c3d4",
  "title": "Platform architecture",
  "iframe": true,
  "height": "560"
}
[/block]

The embed block for an interactive diagram

ReadMe's embed block renders a URL inside the page, and with the iframe option it frames the target directly, height configurable. Point it at an interactive diagram page and readers pan and zoom inside your developer hub, useful on the architecture overview where integrators work out how your system fits theirs.

The framed page must allow embedding. The Datadef embed page does, rendering chrome-less with a small attribution link to the full diagram. For most other pages the plain image is the lighter choice, and freshness is identical either way.

Guides vs API reference pages

A ReadMe hub has two kinds of pages with different authoring models. Guides and landing pages are free-form: you write them, so images and embed blocks go wherever you want. API reference pages are generated from your OpenAPI spec, and their prose comes from the spec itself, description fields on the info object, operations, and parameters, which ReadMe renders as markdown.

That is the route for diagrams on reference pages: put the image markdown inside a description field in the spec, and the generated page carries it. It also means the diagram line lives in the OpenAPI file under version control, which pairs naturally with regenerating the diagram from the same spec, covered in a living diagram from OpenAPI.

Keeping the diagram current, and the limits

The embed follows the diagram within minutes of an edit; updating the diagram when the API or architecture changes is the remaining loop. Datadef ships an MCP server (registry name io.datadef/mcp), so an agent with access to your repo or spec can update the diagram to match, after a merge, in CI, or on request. Datadef does not watch repositories or specs; regeneration happens when an agent call or CI command asks. API access for agents ships with the paid plans.

Limits, stated plainly: the embed URLs require the source project to be shared public and 404 if it goes private. And Datadef syncs diagrams only. Your endpoint documentation, parameter tables, and prose are ReadMe's domain and your review process's problem, part of the wider practice of keeping API docs in sync with code.

FAQ

How do I embed a diagram in ReadMe.com docs?

In guides, use a plain markdown image with an external URL, for example ![Architecture](https://datadef.io/api/embed/your-slug); it renders in both the legacy format and ReadMe Refactored. For an interactive view, use the embed block with the iframe option pointed at https://datadef.io/embed/your-slug.

Do magic blocks still work in ReadMe Refactored?

Yes. ReadMe Refactored is MDX-based, and its processor transpiles the legacy [block:...] JSON syntax for backwards compatibility, so older pages with image or embed magic blocks keep rendering without migration.

Can I put a diagram on a ReadMe API reference page?

Yes, through the OpenAPI spec: reference pages render markdown from description fields, so an image line inside info.description or an operation description appears on the generated page. The diagram reference then lives in the spec under version control.

Does an embedded diagram update automatically in ReadMe?

The page follows the source diagram: the image is served with a five minute cache lifetime, so an edit shows up within minutes with no page edit. The diagram edit itself is not automatic; a person or a connected AI agent makes it when the system changes.

Can I embed a private diagram in a ReadMe hub?

Not as a live embed. The URLs exist only for projects shared public, and a private project turns them into 404s. Developer hubs are usually public anyway, but keep confidential internals out of the diagram you embed.