TOON API
A free JSON to TOON API. Send JSON, YAML, TOML or XML to one endpoint and get TOON back. No key, no signup.
What it does
The endpoint parses your input and encodes it as TOON with the official @toon-format/toon library. TOON uses about 43% fewer tokens than JSON on average (42.6% in the official TOON v4.1 benchmark), so it is a cheap way to shrink LLM prompts from a backend, a script or a no-code tool that can make HTTP calls.
POST https://json2toon.co/api/v1/toonRequest body (JSON):
content(string, required): the raw input. Objects must be stringified first.format(optional):json,yaml,tomlorxml. If omitted, the API tries JSON, YAML, TOML, then XML.options(optional): passed to the TOON encoder, e.g.{"delimiter": "|", "indentSize": 4}.
Try it
This form sends a real request to the API from your browser.
Try it out
Examples
curl
curl -X POST https://json2toon.co/api/v1/toon \
-H "Content-Type: application/json" \
-d '{"content": "{\"users\":[{\"id\":1,\"name\":\"Ann\"},{\"id\":2,\"name\":\"Bob\"}]}", "format": "json"}'JavaScript (fetch)
const data = { users: [{ id: 1, name: "Ann" }, { id: 2, name: "Bob" }] }
const res = await fetch("https://json2toon.co/api/v1/toon", {
method: "POST",
headers: { "Content-Type": "application/json" },
// content must be a string, so stringify your object first
body: JSON.stringify({ content: JSON.stringify(data), format: "json" }),
})
if (!res.ok) throw new Error((await res.json()).error)
const toon = await res.text()Python (requests)
import json, requests
data = {"users": [{"id": 1, "name": "Ann"}, {"id": 2, "name": "Bob"}]}
res = requests.post(
"https://json2toon.co/api/v1/toon",
json={"content": json.dumps(data), "format": "json"},
)
res.raise_for_status()
toon = res.textResponse format
On success the API returns 200 with the TOON document as plain text (not JSON). For the examples above:
users[2]{id,name}:
1,Ann
2,BobIf you leave out format, the response also carries an X-Performance-Warning header suggesting you set it.
Errors
Errors come back as JSON with a single error field:
| Status | Body |
|---|---|
| 400 | {"error": "Content is required"} |
| 400 | {"error": "Failed to parse content as json"} |
| 400 | {"error": "Unsupported format: csv"} |
| 400 | {"error": "Could not auto-detect format. Please specify 'format' or check your input."} |
| 400 | {"error": "Invalid request body"} |
| 500 | {"error": "Failed to convert to TOON: ..."} |
Limits
No API key and no rate limit at the moment. It is a free service with no uptime guarantee, and it only converts to TOON (not back). Your data is processed on our server in memory and not stored; see the privacy policy. The full OpenAPI reference is in the API docs.
API or library?
If your code runs in JavaScript or TypeScript, installing @toon-format/toon is usually better: no network round trip, no dependency on our uptime, it works offline, your data never leaves your machine, and you also get decode(). See the TypeScript install guide or the other languages.
The API is handy when you cannot add a dependency: shell scripts, no-code tools like Zapier or n8n, languages without a TOON library yet, or a quick test before you commit to the format.
Using an AI assistant? Try the MCP server
If you want ChatGPT, Claude, Cursor or VS Code to do the conversion, connect the TOON MCP server instead. It exposes json_to_toon and toon_to_json tools, so it also decodes. To see how many tokens you would save first, paste a sample into the TOON token calculator.
FAQ
Is the TOON API free?
Yes. The JSON to TOON API at json2toon.co/api/v1/toon is free and needs no API key or account.
Does the TOON API have a rate limit?
There is no rate limit today. It is a free hosted service with no SLA, so for high-volume or critical workloads run the @toon-format/toon library yourself.
Which input formats does the API accept?
JSON, YAML, TOML and XML, sent as a string in the content field. Set format to json, yaml, toml or xml, or leave it out and the API auto-detects it.
Can the API convert TOON back to JSON?
No, the REST endpoint only encodes to TOON. To decode TOON to JSON, use the toon_to_json tool on the MCP server, the online converter, or decode() from the @toon-format/toon library.
Is my data stored?
No. The request is converted in memory and the result is returned in the response. Nothing is written to a database.