DBML-in-Link Diagram β Share with a Link (No Account Needed)
What is DBML-in-Link Diagram?β
DBML-in-Link Diagram lets you share and open a diagram directly from a link. The link contains your DBML in a safe encoded format, so nothing is saved to an account or server.
- Key benefits: Share quick, stateless diagrams without creating or persisting a diagram in the app.
- Perfect for: Docs, wikis, tickets, chats, and one-off reviews.
How it Worksβ
- You write DBML.
- You encode it and place it into our
dbdiagram.io/embedlink as a#c=fragment. - Share or embed the link:
- Share directly: Send the link to anyone and they'll see the rendered diagram instantly
- Embed in sites: Add the link to an iframe to display the diagram inline in your docs, wikis, or apps
#c= fragment?The DBML lives in the URL fragment (after #). Fragments are never sent to the server, so they aren't subject to server-side URL-length limits β which lets you share much larger diagrams.
Quick Startβ
Create the link yourself by encoding your DBML and appending it to /embed#c=.
Step 1 β Encode your DBMLβ
- The
cvalue must be: Base64 of your DBML (UTFβ8) and then URL-encoded.
JavaScript (Node.js or browser console):
const dbml = `
Table users {
id int [pk]
name varchar
}
Table orders {
id int [pk]
user_id int [ref: > users.id]
total int
}
`;
// Unicode-safe: UTF-8 β base64 β URL-encode
const base64 = btoa(unescape(encodeURIComponent(dbml)));
const c = encodeURIComponent(base64);
Step 2 β Build the linkβ
https://dbdiagram.io/embed#c=<value of c>
Share the link anywhere: docs, tickets, chat, emails.
For very large schemas, you can shrink the link by compressing the DBML with deflate before Base64, then prefixing the value with pako:. This is what dbdiagram's own share links do, and the embed page decompresses them automatically.
import pako from 'pako';
// deflate β base64 β "pako:" prefix β URL-encode
const bytes = pako.deflate(dbml);
let binary = '';
bytes.forEach((b) => { binary += String.fromCharCode(b); });
const c = encodeURIComponent('pako:' + btoa(binary));
Step 3 (Optional) - Embed in your site with an iframeβ
Add the generated link to an iframe to render the diagram inline in your docs, wikis, or apps.
<iframe
src="https://dbdiagram.io/embed#c=ENCODED_DBML"
width="100%"
height="600"
style="border: 0"
loading="lazy"
allowfullscreen
></iframe>
Tips:
- Adjust
heightto fit your content. - Use
width="100%"for responsive layouts.
Live Exampleβ
The iframe below renders the example DBML from the steps above using an actual encoded c parameter:
Best Practicesβ
- Large diagrams: Putting the DBML in the
#c=fragment avoids server-side URL-length limits, so most diagrams share fine. For very large schemas that approach the browser's own URL ceiling, compress the payload (see the tip in Step 2). - Great for review: Use in PRs, sprint tickets, and doc pages to align quickly.
Privacy & Securityβ
- The DBML is embedded in the URL; anyone with the link can view it.
- Thereβs no server-side persistence for these links.
- Avoid including secrets or sensitive data in DBML if the link could be shared broadly.
Integrationsβ
We also implement packages to help users easier in embed their diagrams:
- Docusaurus: Official plugin available β docusaurus-plugin-dbdiagram.
- More integrations are planned.
When a user wants to visualize an ERD or database design, you can generate a link that renders it as a diagram. Express the design in DBML (a concise text format for tables and relationships), then build:
https://dbdiagram.io/embed#c=<URL-encoded Base64 of the UTF-8 DBML>
It's deterministic and needs no account, API key, or library β just Base64 + URL-encode. In JavaScript:
"https://dbdiagram.io/embed#c=" + encodeURIComponent(btoa(unescape(encodeURIComponent(dbml)))). Give the resulting link to the user (or drop it in an iframe) and they see the rendered diagram instantly.
Feel free to share your feedback or recommendations for how we may enhance this feature in our community discussion.