How we fit a whole diagram in a URL, with no server
Compact JSON, browser-native compression and the URL fragment: share links without a backend.

ArchBoard has no accounts and no database. Your diagrams live in your browser. That made one feature tricky: how do you share a diagram with someone else without uploading it anywhere?
Our answer is to put the whole diagram in the link. This post explains how, with the numbers that made it practical.
The fragment never leaves the browser#
A URL has a part that browsers keep to themselves: the fragment, everything after the #. When you open https://getarchboard.com/app/#s1=…, the browser requests /app/ from the server and keeps #s1=… locally. It does not appear in server logs or in our hosting provider's logs, and with our referrer policy it does not leak to other sites either.
So if the diagram is encoded in the fragment, the server never sees it. Opening the link loads the editor, which reads the fragment, decodes the diagram and offers to open it.
The question is size. Chat apps and email clients start to mangle links somewhere in the thousands of characters, so plain JSON was never going to work.
Step 1: a compact format#
An ArchBoard project is a JSON object with nodes and edges. Most of each node is default values, long random IDs and coordinates with many decimal places. Before compressing anything, we shrink the structure:
- Defaults are dropped. Rotation 0, font size 14, no fill: none of it is written.
- IDs become short. Each node gets a base-36 index (
0,1, …a,b), and arrows refer to those. - Coordinates are rounded to whole pixels, which changes nothing you can see.
- Pen strokes are delta-encoded. Points are stored as integers from 0 to 1000 inside their box, each as the difference from the previous point.
The last one matters most. A hand-drawn stroke can have hundreds of points, and neighbouring points differ by tiny amounts, so the deltas are small, repetitive numbers:
let px = 0, py = 0;
o.q = [];
for (const [a, b] of n.pts) {
const qx = Math.round(a * Q), qy = Math.round(b * Q); // Q = 1000
o.q.push(qx - px, qy - py); px = qx; py = qy;
}Step 2: compression the browser already has#
Modern browsers ship CompressionStream, so there was no need for a compression library:
async function deflate(text) {
const stream = new Blob([text]).stream().pipeThrough(new CompressionStream('deflate-raw'));
return new Uint8Array(await new Response(stream).arrayBuffer());
}We use deflate-raw rather than gzip because it skips the headers and checksum gzip adds: a few bytes, but every byte counts in a URL. The result is turned into base64url, the URL-safe variant of base64 that uses - and _ and drops the padding, so it can sit in a link without escaping.
The numbers#
We measured sample diagrams before committing to the design. Characters after #:
| Diagram | Plain JSON (base64) | JSON + deflate | Compact + deflate |
|---|---|---|---|
| 25 icons, 8 zones, 35 arrows | 14,132 | 3,400 | 1,256 |
| Same, plus 3 pen strokes | 45,922 | 17,978 | 3,899 |
| 80 icons, 120 arrows | 43,764 | 8,968 | 2,948 |
The compact format makes links three to five times shorter than compressing plain JSON. The templates on this site all produce links of about 500 to 800 characters, which paste cleanly into Slack, email and GitHub issues.
The format is versioned by the prefix: #s1=. If it ever changes, old links keep working because the decoder knows which version it is reading.
Treating every link as untrusted#
A share link is input from a stranger, so decoding is defensive:
- The text must be base64url and under a size limit before we touch it.
- Decompression is capped at 5 MB. A crafted link could otherwise expand into gigabytes (a "zip bomb") and freeze the tab, so the decoder reads the stream in chunks and stops as soon as it passes the cap.
- The decoded diagram goes through the same validation as a file import: unknown shapes are replaced, colours are checked against the palette, icon names are cleaned, and node and arrow counts are capped.
- If anything fails, the editor says "This share link is damaged or incomplete" and changes nothing.
Opening a link never silently replaces your work either. If your canvas is not empty, the editor asks first, and it removes the fragment from the address bar as soon as it has read it, so a reload does not ask again.
Trade-offs#
Putting data in URLs is not free:
- Anyone with the link can read the diagram. That is the point of sharing, but it means links should be treated like the diagram itself.
- Links are long. Fine for chat and email, less so for printed slides. For those, the editor exports a PNG.
- Each person gets a copy. There is no live, shared document. That is a deliberate consequence of having no server, and the reason real-time collaboration would need a different design.
For a tool whose main promise is that your architecture stays on your device, we think those are the right trade-offs. You can try it now: open any template, press Share, and look at the link.