npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

toon-to-any

v2.0.8

Published

JSON ↔ TOON converter with full recursive nested support and high-performance streaming.

Downloads

80

Readme

toon-to-any

⚡ Make your API responses 10× faster by converting heavy JSON data into a compact TOON format — ideal for large datasets, real-time dashboards, and high-traffic backends.

npm version downloads license typescript

toon-to-any is a fast and lightweight transformer that converts deep/nested JSON structures into a compact, columnar TOON format, with full support for:

  • ✔ deeply nested objects
  • ✔ arrays of objects
  • ✔ arrays of primitives
  • ✔ mixed/nested array/object structures
  • ✔ streaming large MongoDB/SQL datasets
  • ✔ full round-trip: JSON → TOON → JSON

Designed for high-performance backend apps and clients needing lightweight, predictable structured data exchange.

Maintained by Truncate Technologies Pvt. Ltd.
🌐 https://www.truncate.in


🚀 Why use toon-to-any?

✅ 1. Make your API significantly faster

  • Reduces JSON payload size by up to 80%
  • Sends columnar TOON format instead of large repetitive JSON
  • Clients reconstruct full JSON instantly

Perfect for APIs returning thousands to millions of rows.

✅ 2. Full recursive support

Automatically converts nested structures at ANY depth:

object → toon
array of objects → toon
nested arrays → toon
deeply mixed JSON → recursive toon

Fully reversible:

toon → original JSON (lossless)

✅ 3. Stream massive datasets

MongoDB → cursor → TOON rows → client
No memory spikes. Suitable for millions of records.

✅ 4. Optimized for Node.js + React

Backend sends small TOON payload → frontend expands to JSON.

✅ 5. Zero dependencies + full TypeScript support

Lightweight, fast, production-ready.


📦 Install

npm install toon-to-any

⚡ CLI Usage

toon-to-any input.json output.toon.json

🔄 JSON → TOON

import { jsonToToon } from "toon-to-any";
const toon = jsonToToon(data);

🔁 TOON → JSON

import { toonToJson } from "toon-to-any";
const arr = toonToJson(toon);

🌊 Streaming (ideal for huge datasets)

import { createToonStream } from "toon-to-any";
db.stream().pipe(createToonStream(["id","name"])).pipe(res);

🍃 MongoDB → Full Recursive TOON

import { jsonToToon } from "toon-to-any";

app.get("/api/products/toon", async (req, res) => {
  const docs = await db.collection("products").find().toArray();
  const toon = jsonToToon(docs);  
  res.json(toon);
});

All nested fields (categories, variants, specs, images, etc.) are automatically TOON-converted.


🧪 Client-Side Example — TOON → JSON (React)

async function fetchProducts() {
  const res = await fetch("/api/products/toon");
  const toon = await res.json();

  const data = toonToJson(toon);
  setProducts(data);
}

💡 When Should You Use toon-to-any?

Use this when:

  • handling large JSON arrays (10k–1M rows)
  • needing high-performance APIs
  • wanting faster network responses
  • reducing payload size matters
  • exporting to BI tools / dashboards
  • syncing large datasets between backend ↔ frontend
  • looking for a simple alternative to Protobuf/Avro/MessagePack

📈 Performance Notes

| Operation | Speed | Notes | |------------------|-------|-------| | JSON → TOON | ⚡ Fast | No schema needed | | TOON → JSON | ⚡ Fast | Great for UI rendering | | Streaming | 🚀 Extreme | Perfect for MongoDB cursor streams | | Nested JSON | ✔ Unlimited depth | Fully supported |

Typical compression:

  • 30–60% smaller for flat arrays
  • 50–80% smaller for deeply nested payloads
  • O(1) memory usage when streaming

🤝 Maintained By

Truncate Technologies Pvt. Ltd.
Enterprise Software & AI Solutions
🌐 https://www.truncate.in
📧 [email protected]


📄 License

MIT © Truncate Technologies Pvt. Ltd.