Docs menu
URL length
How long a chart URL can be, and how to keep a spec short.
The whole spec travels in the URL, so a chart's URL grows with its data.
The limit
The query string can be up to 8 KB, since some proxies and clients refuse longer URLs. Base64url makes JSON a third longer, which leaves room for about 6,142 bytes of spec JSON.
Some places that show images set their own, lower limits. Slack refuses image URLs over 3,000 characters, which fits about 2,222 bytes of JSON.
How long specs are
The charts in these docs, measured when the site was built:
| Chart | Spec JSON | base64url URL | Plain JSON URL |
|---|---|---|---|
| Quick start bar chart | 199 bytes | 303 characters | 400 characters |
| Slack deploys chart | 255 bytes | 377 characters | 496 characters |
| Revenue OG image | 367 bytes | 527 characters | 672 characters |
A dozen values and a title take a few hundred characters, far from any limit. A spec reaches the limit at around a thousand values, or sooner with long labels. Plain JSON after ?c= makes a longer URL than base64url, because percent-encoding turns each quote and brace into three characters.
Keep a spec short
- Leave out fields at their default.
"theme": "default","mode": "light","scale": 2and"format": "png"change nothing. - Send JSON without indentation.
JSON.stringify(spec)and Python'sjson.dumpswithseparators=(",", ":")do. - Use short labels:
"Mon"rather than"Monday 6 October". - Round values to what the chart shows. An axis in
compactformat draws 31,412.37 as 31.4k, so send 31400. - Group the data when there's more of it than the chart can show: weeks instead of days, the top ten and "Other".
When a URL is too long
The playground warns you when a spec's URL is over the limit. The API sends back an error image with the query_too_large code, or a 414 with errors=status.