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

@rfanth/tjson

v0.6.1

Published

Text JSON (TJSON) - a readability optimized, round trip compatible alternative to JSON

Readme

@rfanth/tjson

JavaScript/TypeScript bindings for TJSON — a readable, round-trip-safe alternative to JSON.

TJSON represents the same data model as JSON but renders it in a way that feels like text: bare strings and keys, pipe tables for arrays of objects, multiline string literals, line folding, and comments. It is not a superset or subset of JSON — it is a different surface syntax for the same underlying data, fully convertible in both directions without data loss.

Input JSON

{
  "name": "Alice",
  "age": 30,
  "active": true,
  "bio": "She is a developer.\nShe loves Rust.",
  "scores": [90, 85, 92],
  "tags": ["rust", "wasm", "json", "serialization"],
  "team": [
    {"name": "Alice", "age": 30, "role": "admin"},
    {"name": "Bob",   "age": 25, "role": "user"},
    {"name": "Carol", "age": 35, "role": "user"}
  ]
}

TJSON output

  name: Alice    age:30    active:true
  bio: ``
| She is a developer.
| She loves Rust.
   ``
  scores:  90, 85, 92
  tags:   rust,  wasm,  json,  serialization
  team:
    |name    |age  |role    |
    | Alice  |30   | admin  |
    | Bob    |25   | user   |
    | Carol  |35   | user   |

Installation

npm install @rfanth/tjson

Or via CDN (no bundler needed):

import { parse, stringify, fromJson, toJson } from 'https://esm.sh/@rfanth/tjson';

Usage

import { parse, stringify, fromJson, toJson } from '@rfanth/tjson';

// JS value → TJSON
const tjson = stringify({ name: 'Alice', scores: [95, 87, 92] });

// TJSON → JS value
const value = parse(tjson);

// With options
const canonical = stringify({ name: 'Alice' }, { canonical: true });
const narrow    = stringify({ name: 'Alice' }, { wrapWidth: 40, stringArrayStyle: 'preferSpaces' });

// String pipeline variants (if you already have a JSON string)
const tjson2 = fromJson('{"name":"Alice"}');
const json   = toJson(tjson2);

stringify accepts any JSON-serializable JS value and returns a TJSON string. parse accepts a TJSON string and returns a JS value — just like JSON.parse. fromJson/toJson are the string-in/string-out variants for JSON string pipelines.

All four functions throw an Error on invalid input.

Options

stringify and fromJson accept an optional StringifyOptions object. TypeScript users get full autocomplete and inline documentation for all options — hover over any field in your editor.

Options use camelCase in JavaScript. The underlying library's Rust API uses snake_case and idiomatic Rust, but exposes the same options.

Key options:

| Option | Default | Description | |---|---|---| | canonical | false | One key per line, no packing, no tables | | wrapWidth | 80 | Column wrap limit; 0 for unlimited | | tables | true | Render arrays-of-objects as pipe tables | | multilineStrings | true | Use \`blocks for strings containing newlines | |inlineObjects|true| Pack multiple key-value pairs onto one line | |inlineArrays|true| Pack multiple array items onto one line | |stringArrayStyle|"preferComma"` | How to pack all-string arrays |

Advanced options:

| Option | Default | Description | |---|---|---| | bareStrings | "prefer" | Use bare (unquoted) string values when spec permits | | bareKeys | "prefer" | Use bare (unquoted) object keys when spec permits | | forceMarkers | false | Force explicit [ / { indent markers on single-step indents | | multilineStyle | "bold" | Multiline block style ("bold", "floating", "light", etc.) | | multilineMinLines | 1 | Min newlines in a string before using a multiline block | | indentGlyphStyle | "auto" | When to wrap deeply nested content in /< /> glyphs | | indentGlyphMarkerStyle | "compact" | Where to place the opening /< glyph | | tableUnindentStyle | "auto" | How to reposition wide tables toward the left margin | | tableMinRows | 3 | Min rows required to render a table | | tableMinColumns | 3 | Min columns required to render a table | | tableMinSimilarity | 0.8 | Min fraction of rows sharing a column | | tableColumnMaxWidth | 40 | Bail on table if any column exceeds this width | | fold | — | Set all four fold styles at once; more specific options override | | numberFoldStyle | "auto" | How to fold long numbers across lines | | stringBareFoldStyle | "auto" | How to fold long bare strings | | stringQuotedFoldStyle | "auto" | How to fold long quoted strings | | stringMultilineFoldStyle | "none" | How to fold multiline block continuation lines |

Experimental options (may change or be removed in a future version):

| Option | Default | Description | |---|---|---| | kvPackMultiple | 2 | Spacing multiplier between packed key-value pairs (1–4; spaces = value × 2) | | multilineMaxLines | 10 | Max lines in a "floating" block before falling back to "bold" | | tableFold | false | Fold long table rows across continuation lines |

Full option reference with inline documentation is in the TypeScript types bundled with the package.

Resources

License

BSD-3-Clause