ToonUse provides a high-performance API to convert standard JSON data into Token-Oriented Object Notation (TOON). This format is optimized for Large Language Models, reducing token usage by 30-60% while maintaining data integrity.
Authenticate your requests using an API Key. You can generate one in your Profile Dashboard.
X-API-Key: tk_your_api_key_here
/convert/json-to-toonAccepts a JSON object or array and returns the compact TOON string.
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | Object | Array | Yes | The JSON object or array to be converted. |
| structured | Boolean | No | Default: false. If set to true, uses advanced structural compression for better token savings on complex nested data. |
{
"data": {
"users": [
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]
},
"structured": true // Optional: Set to true for structured TOON format
}{
"result": "users[2]{id,name}:\n1,Alice\n2,Bob",
"tokens_saved": 45.2,
"original_size": 85,
"new_size": 46
}/convert/toon-to-jsonReconstructs the original JSON structure from a TOON string.
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | String | Yes | The TOON format string to be converted back to JSON. |
{
"data": "users[2]{id,name}:\n1,Alice\n2,Bob"
}{
"result": {
"users": [
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]
},
"tokens_saved": 0,
"original_size": 46,
"new_size": 85
}curl -X POST "https://api.toonuse.com/convert/json-to-toon" \
-H "Content-Type: application/json" \
-H "X-API-Key: tk_your_key" \
-d '{"data": {"hello": "world"}, "structured": true}'import requests
url = "https://api.toonuse.com/convert/json-to-toon"
headers = {
"X-API-Key": "tk_your_key",
"Content-Type": "application/json"
}
data = {
"data": {
"users": [{"id": 1, "name": "Alice"}]
},
"structured": true
}
response = requests.post(url, json=data)
print(response.json())const axios = require('axios');
async function convert() {
const response = await axios.post(
'https://api.toonuse.com/convert/json-to-toon',
{
data: { users: [{ id: 1, name: 'Alice' }] },
structured: true
},
{
headers: { 'X-API-Key': 'tk_your_key' }
}
);
console.log(response.data);
}
convert();curl -X POST "https://api.toonuse.com/convert/toon-to-json" \
-H "Content-Type: application/json" \
-H "X-API-Key: tk_your_key" \
-d '{"data": "users[2]{id,name}:\n1,Alice\n2,Bob"}'import requests
url = "https://api.toonuse.com/convert/toon-to-json"
headers = {
"X-API-Key": "tk_your_key",
"Content-Type": "application/json"
}
data = {
"data": "users[2]{id,name}:\n1,Alice\n2,Bob"
}
response = requests.post(url, json=data)
print(response.json())const axios = require('axios');
async function convertBack() {
const response = await axios.post(
'https://api.toonuse.com/convert/toon-to-json',
{
data: "users[2]{id,name}:\n1,Alice\n2,Bob"
},
{
headers: { 'X-API-Key': 'tk_your_key' }
}
);
console.log(response.data);
}
convertBack();