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

v1.0.0

Published

A TypeScript library for converting between JSON and TOON formats - a structured, human-readable representation of JSON data

Downloads

10

Readme

JSON to TOON Converter

A TypeScript library for converting between JSON and TOON formats. The TOON format is a structured, human-readable representation of JSON data that presents information in a tabular and hierarchical format.

Installation

npm install json-to-toon

Usage

Converting JSON to TOON

import { toToon } from 'json-to-toon';

const json = {
  metadata: { version: 1, author: "test" },
  items: [
    { id: 1, name: "Item1" },
    { id: 2, name: "Item2" }
  ],
  tags: ["alpha", "beta", "gamma"]
};

const toon = toToon(json);
console.log(toon);
// Output:
// metadata:
//   version: 1
//   author: test
// items:
//   [2,]{id,name}:
//     1,Item1
//     2,Item2
// tags:
//   [3]: alpha,beta,gamma

Converting TOON back to JSON

import { fromToon } from 'json-to-toon';

const toon = `metadata:
  version: 1
  author: test
tags:
  [3]: alpha,beta,gamma`;

const json = fromToon(toon);
console.log(json);
// Output: 
// {
//   metadata: { version: 1, author: 'test' },
//   tags: ['alpha', 'beta', 'gamma']
// }

API

toToon(json: JsonValue): string

Converts a JSON value to its TOON string representation.

fromToon(toon: string): JsonValue

Converts a TOON string back to its original JSON value.

JsonToToonConverter

A class containing the core conversion methods:

  • static toToon(json: JsonValue): string
  • static fromToon(toon: string): JsonValue

TOON Format Specification

The TOON format is a structured representation of JSON data with the following rules:

Basic Types

  • nullnull
  • truetrue
  • falsefalse
  • Numbers → Plain numbers (e.g., 42, 3.14)
  • Strings → Plain strings (e.g., hello)

Arrays

  • Simple arrays → [count]: value1,value2,value3
  • Object arrays with consistent structure → [count,]{key1,key2}: value1,value2

Objects

  • Simple objects → Key-value pairs with indentation
  • Nested objects → Hierarchical structure with proper indentation

Examples

Simple object:
name: John
age: 30

Nested object:
user:
  name: John
  age: 30

Array of primitives:
tags: [3]: alpha,beta,gamma

Array of objects:
items: [2,]{id,name}:
  1,Item1
  2,Item2

Development

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

License

MIT