json-toon-transformer
v1.0.2
Published
Lightweight utilities to convert JSON <-> TOON (column-style compact notation).
Maintainers
Readme
🌀 json-toon-transformer
A lightweight, zero-dependency utility to convert JSON arrays into a compact TOON (column-style) format — and back to JSON.
TOON format reduces payload size, improves API performance, and is ideal for mobile apps, dashboards, analytics, and backend services.
✨ Features
- 🔄 JSON → TOON conversion
- 🔄 TOON → JSON conversion
- ⚡ Extremely lightweight (zero runtime dependencies)
- 📉 Compact column-style output (less data, faster transfers)
- 🧹 Clean and minimal API
- 🟦 Full TypeScript support (ships with
.d.ts) - 🧩 Works in Node.js, Next.js, and Deno
📦 Installation
Using npm:
npm install json-toon-transformerUsing yarn:
yarn add json-toon-transformerUsing pnpm:
pnpm add json-toon-transformer🚀 Quick Start
import { jsonToToon, toonToJson } from 'json-toon-transformer';
const json = {
reviews: [
{ id: 201, customer: "Rahul Shah", rating: 5, comment: "Fantastic!", verified: true }
]
};
// Convert JSON → TOON
const toon = jsonToToon(json);
console.log(toon);
// Convert TOON → JSON
const parsed = toonToJson(toon);
console.log(parsed);📝 Example Output
Input JSON
{
"reviews": [
{ "id": 201, "customer": "Rahul Shah", "rating": 5, "comment": "Fantastic!", "verified": true }
]
}TOON Output
reviews[1]{
id, customer, rating, comment, verified
}
201, Rahul Shah, 5, Fantastic!, trueMuch smaller. Much faster.
📚 API Reference
jsonToToon(json: Record<string, any>): string
Converts a JSON array object into a compact TOON format.
toonToJson(toon: string): Record<string, any>
Parses TOON formatted text back into JSON.
🌍 When To Use
- Reduce API response size
- Send large lists to mobile clients
- Transform data into column-structured format
- Analytics / BI pipelines
- Custom CSV-like data interchange
- Performance-optimized server responses
🛠 Development
Clone and install dependencies:
npm installBuild:
npm run buildRun tests:
npm test📄 License
MIT © 2025 Lugunova
