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

json-to-toon-converter

v1.0.0

Published

A TypeScript package to convert JSON to Toon format and vice versa

Readme

JsonToToon

A TypeScript package that converts JSON to a compact "Toon" format and vice versa. The Toon format is a human-readable, space-efficient alternative to JSON that maintains full compatibility with all JSON data types.

Installation

# Using pnpm
pnpm add JsonToToon

# Using npm
npm install JsonToToon

# Using yarn
yarn add JsonToToon

Usage

Convert JSON to Toon Format

import { jsonToToon } from 'JsonToToon';

// From JSON string
const json = '{"name": "John", "age": 30, "active": true}';
const toon = jsonToToon(json);
console.log(toon); // {name:"John",age:30,active:true}

// From JavaScript object
const obj = { name: 'John', age: 30, active: true };
const toon2 = jsonToToon(obj);
console.log(toon2); // {name:"John",age:30,active:true}

Convert Toon Format to JSON

import { toonToJson } from 'JsonToToon';

const toon = '{name:"John",age:30,active:true}';
const json = toonToJson(toon);
console.log(json); // {"name":"John","age":30,"active":true}

Round-trip Conversion

import { jsonToToon, toonToJson } from 'JsonToToon';

const original = '{"users": [{"name": "John", "scores": [10, 20, 30]}]}';
const toon = jsonToToon(original);
const back = toonToJson(toon);

// The data is preserved
const originalObj = JSON.parse(original);
const backObj = JSON.parse(back);
console.log(originalObj); // Same as backObj

Toon Format Specification

The Toon format is a compact representation of JSON data:

  • Objects: {key:value,key2:value2} (no quotes on valid identifier keys, minimal whitespace)
  • Arrays: [item1,item2,item3]
  • Strings: "text" or 'text' (quoted)
  • Numbers: 123, 45.67, -10
  • Booleans: true, false
  • Null: null
  • Nested structures: Fully supported

Examples

| JSON | Toon Format | |------|-------------| | {"name": "John"} | {name:"John"} | | [1, 2, 3] | [1,2,3] | | {"active": true, "count": 42} | {active:true,count:42} | | {"nested": {"key": "value"}} | {nested:{key:"value"}} |

API Reference

jsonToToon(json: string | object): string

Converts a JSON string or JavaScript object to Toon format.

Parameters:

  • json - A JSON string or JavaScript object

Returns: A string in Toon format

Throws: Error if the input is invalid JSON

toonToJson(toon: string): string

Converts a Toon format string to JSON string.

Parameters:

  • toon - A string in Toon format

Returns: A JSON string

Throws: Error if the input is invalid Toon format

Features

  • ✅ Full support for all JSON data types
  • ✅ Nested objects and arrays
  • ✅ TypeScript support with type definitions
  • ✅ Zero dependencies
  • ✅ Comprehensive test coverage
  • ✅ Round-trip conversion maintains data integrity

Development

Building

pnpm run build

Testing

pnpm test

Watch Mode

pnpm run test:watch

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.