TOON Converter API

API Documentation

Overview

The TOON Converter API allows you to programmatically convert between JSON and TOON (Token-Oriented Object Notation) formats. TOON reduces token usage by 30-60% compared to JSON, making it ideal for AI/LLM applications.

Base URL: https://toonverter.com/api

Endpoints

POST /api/convert

Convert between JSON and TOON formats. This endpoint validates input and performs the conversion.

Request Body

Parameter Type Required Description
input_data string Yes The JSON or TOON string to convert
direction string Yes Either "json_to_toon" or "toon_to_json"

Response

{ "success": true, "output": "string - The converted output", "output_format": "json | toon", "message": "Conversion successful" }

Example: Convert JSON to TOON

curl -X POST "https://toonverter.com/api/convert" \ -H "Content-Type: application/json" \ -d '{ "input_data": "{\"name\": \"Alice\", \"age\": 30}", "direction": "json_to_toon" }'

Example: Python

import requests response = requests.post( "https://toonverter.com/api/convert", json={ "input_data": '{"name": "Alice", "age": 30}', "direction": "json_to_toon" } ) print(response.json())
POST /api/validate

Validate JSON or TOON input without performing conversion. Useful for checking format correctness before processing.

Request Body

Parameter Type Required Description
input_data string Yes The JSON or TOON string to validate
direction string Yes Either "json_to_toon" (validates JSON) or "toon_to_json" (validates TOON)

Response

{ "valid": true, "message": "Input is valid" }

Example

curl -X POST "https://toonverter.com/api/validate" \ -H "Content-Type: application/json" \ -d '{ "input_data": "{\"name\": \"Alice\"}", "direction": "json_to_toon" }'
GET /api/ai-tools

Get AI-friendly tool descriptions for AI agents. Returns structured information about available API endpoints in a format optimized for AI consumption.

Note: This endpoint returns JSON. For human-readable documentation, see this page or visit /api/ai-tools.

Error Handling

All endpoints return appropriate HTTP status codes:

  • 200 OK: Request successful
  • 400 Bad Request: Invalid input format (JSON or TOON syntax error)
  • 500 Internal Server Error: Unexpected server error

Error responses include a detail field with a descriptive error message.

About TOON Format

TOON (Token-Oriented Object Notation) is a compact, human-readable serialization format designed to reduce token usage when passing structured data to Large Language Models (LLMs).

Benefits

  • 30-60% fewer tokens compared to JSON
  • Human-readable format
  • Supports tabular arrays for efficient data representation
  • Indentation-based structure similar to YAML

Example

JSON:
{ "users": [ {"id": 1, "name": "Alice", "role": "admin"}, {"id": 2, "name": "Bob", "role": "user"} ] }
TOON:
users[2]{id,name,role}: 1,Alice,admin 2,Bob,user