DEV Community

Cover image for Why I Built TOON: A Better Data Format for APIs
Manoj Gowda
Manoj Gowda

Posted on

Why I Built TOON: A Better Data Format for APIs

Introducing TOON — Typed Object Oriented Notation

JSON is everywhere.

It powers APIs, microservices, automation tools, and frontend apps.

But as applications scale, JSON becomes:

verbose

repetitive

bandwidth heavy

lacking type structure

That’s why I built TOON (Typed Object Oriented Notation) — a compact, typed, and developer-friendly alternative.

👉 npm: https://www.npmjs.com/package/toonkit

🧠 What is TOON?

TOON = Typed Object Oriented Notation

It combines:

✔ schema
✔ data
✔ types
✔ compact structure

Think of it as JSON + schema + compression + readability.

❌ The Problem with JSON

A typical API response:

{
"employees": [
{ "id": 1, "name": "Riya", "salary": 90000, "active": true },
{ "id": 2, "name": "John", "salary": 80000, "active": false }
]
}

Problems:

repeated keys increase payload size

no built-in typing

inefficient for large responses

✅ The TOON Solution
employees[2]{id:n,name:s,salary:n,active:b}:
1,Riya,90000,true
2,John,80000,false

✔ smaller payload
✔ typed schema
✔ readable structure
✔ faster parsing

🔄 Parsed Output
[
{ id: 1, name: "Riya", salary: 90000, active: true },
{ id: 2, name: "John", salary: 80000, active: false }
]
🧬 Supported Data Types
Code Type
n number
s string
b boolean
nl null
j JSON object
a array
⚡ Why Developers Like TOON
✅ Smaller Payload Size

Less bandwidth, faster APIs.

✅ Built-in Type Safety

Schema ensures consistent data.

✅ Multi-Resource Responses

Return multiple datasets in one response.

✅ Human Readable

Debug easily without extra tools.

✅ Frontend ⇄ Backend Symmetry

Same format everywhere.

📦 Install
npm install toonkit
🧩 Example Usage
Convert JSON → TOON
import { sendToon } from "toonkit";

const payload = sendToon({
employees: [{ id: 1, name: "Riya" }]
});
Convert TOON → JSON
import { receiveToon } from "toonkit";

const data = receiveToon(text);
🖥 Express Example
const express = require("express");
const { reqGetToon, resSendToon } = require("toonkit");

const app = express();
app.use(express.text());

app.post("/api", (req, res) => {
const data = reqGetToon(req);
resSendToon(res, data);
});
🧠 When TOON is Useful

✅ APIs returning multiple resources
✅ automation & bots
✅ low bandwidth environments
✅ Chrome extensions
✅ microservices
✅ real-time systems

🌐 Documentation

Full docs & playground:

👉 https://toonkit.manojgowda.in

💻 GitHub

https://github.com/ManojGowda89/toonkit

💬 Why I Built TOON

I wanted a data format that:

reduces payload size

simplifies API responses

provides typing without complexity

works seamlessly in JavaScript

TOON is my attempt to make data exchange simpler and more efficient.

🚀 Try TOON Today

👉 https://www.npmjs.com/package/toonkit

If you find it useful, I’d love your feedback and contributions.

Top comments (1)

Collapse
 
fredbrooker_74 profile image
Fred Brooker

have you ever heard about Protocol Buffers by Google? (Protobuf)