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)