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

@jsonzen/core

v1.0.0

Published

Pure-TypeScript JSON engine: format, validate, diff, query, convert. The library behind jsonzen.dev and the jsonzen CLI.

Readme


Install

pnpm add @jsonzen/core

or npm i @jsonzen/core · yarn add @jsonzen/core · bun add @jsonzen/core


Why

Every JSON tool you reach for in an editor — parse, format, validate, diff, query, convert, encrypt — wrapped in one tree-shakable package with Result<T, E> instead of throws and zero browser coupling. Runs in Node, edge runtimes, workers, or the browser. The same code powers jsonzen.dev and the jsonzen CLI.


What's in the box

@jsonzen/core/json

Parse, format, minify, validate, diff, equal, flatten, mutate.

parseJson · validateJson · diffJson

@jsonzen/core/jwt

Decode header, payload, and claims. No signature verification.

decodeJwt

@jsonzen/core/query

JSONPath and JMESPath behind a single API.

runQuery · pathToJsonPath

@jsonzen/core/convert

YAML, CSV, TypeScript, Zod, Pydantic, JSON Schema (both directions).

jsonToYaml · jsonToSchema · jsonFromSchema

@jsonzen/core/crypto

Argon2id key derivation + XChaCha20-Poly1305 envelopes.

deriveMasterKey · encryptSnippet · decryptSnippet

@jsonzen/core/share

URL-fragment share links, plain or password-protected. Zero server state.

encodeShare · encodePasswordShare

@jsonzen/core/tools

Canonical tool registry shared with the web app and CLI.

NAV_TOOLS · groupedNavTools

@jsonzen/core/types

Result<T, E> discriminated union plus ok and err constructors.

Result · ok · err

@jsonzen/core/config

Per-tool config shapes and their DEFAULTS literal.

FormatConfig · CsvConfig · YamlConfig

Every subpath is tree-shakable. Import only what you need: import { parseJson } from '@jsonzen/core/json'.


Quick start

Parse and format a JSON document. Five lines. No exceptions thrown.

import { formatJson } from '@jsonzen/core/json';

const result = formatJson('{"port":8080,"host":"localhost"}', { indent: 2 });
if (result.ok) {
  console.log(result.value);
}

Every operation that can fail returns a Result<T, E>{ ok: true, value } on success, { ok: false, error } on failure. Type narrowing does the rest.


Examples

import { runQuery } from '@jsonzen/core/query';

const result = runQuery({
  language: 'jsonpath',
  query: '$.users[*].email',
  jsonText: JSON.stringify({ users: [{ email: 'a@x' }, { email: 'b@x' }] }),
});
if (result.ok) {
  console.log(result.value.matches); // ['a@x', 'b@x']
}

JMESPath users pass language: 'jmespath' and write the expression in JMESPath syntax. Same Result shape.

import { validateJson } from '@jsonzen/core/json';

const result = validateJson(
  '{"port": 8080}',
  JSON.stringify({
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    type: 'object',
    properties: { port: { type: 'integer' } },
    required: ['port'],
  }),
);
if (result.ok) {
  console.log(result.value.valid); // true
}

Draft-07 and Draft-2019-09 are auto-detected from the schema's $schema header. Schemas above the depth/node caps short-circuit with a typed error before Ajv ever sees them.

import {
  deriveMasterKey,
  encryptSnippet,
  decryptSnippet,
  generateSalt,
} from '@jsonzen/core/crypto';

const salt = generateSalt();
const masterKey = deriveMasterKey('correct horse battery staple', salt);
const envelope = encryptSnippet(masterKey, JSON.stringify({ secret: 1 }));
const plaintext = decryptSnippet(masterKey, envelope);
// plaintext === '{"secret":1}'

Argon2id derivation, XChaCha20-Poly1305 ciphertext, per-snippet data keys wrapped with the master key so passphrase rotation only rewrites the small wrapper — not every ciphertext.

import { jsonToTypeScript } from '@jsonzen/core/convert';

const result = jsonToTypeScript('{"name":"alice","age":30,"roles":["admin","editor"]}', {
  topLevelName: 'User',
  exportType: 'interface',
});
if (result.ok) {
  console.log(result.value);
  // export interface User { name: string; age: number; roles: string[]; }
}

The same module ships jsonToZodSchema, jsonToPydantic, and jsonToSchema for JSON Schema inference.

import { diffJson } from '@jsonzen/core/json';

const result = diffJson('{"a":1,"b":2}', '{"a":1,"b":3,"c":4}');
if (result.ok) {
  for (const change of result.value.changes) {
    console.log(change.kind, change.path, change.before, '→', change.after);
    // modified /b 2 → 3
    // added    /c undefined → 4
  }
}

kind is 'added' | 'removed' | 'modified'. path is a JSON Pointer. arrayMatching: 'value' switches array diffs from index-by-index to LCS-style.


Design rules

Pure logic only. Every public function is deterministic and side-effect-free. No fetch, no localStorage, no console.log. Safe in the browser, Node, edge runtimes, or workers.

Result types over throws. Operations that can fail return Result<T, E> — the ok: boolean-discriminated union from @jsonzen/core/types — instead of throwing. Crypto is the one exception: it throws on tampered ciphertext because there is nothing the caller can usefully do besides treat the input as hostile.

No DOM, no React, no globals. Build once, run anywhere.

Enforced by an ESLint rule set with complexity ≤ 8, no any, no non-null assertions, no console.log, 95 % line and branch coverage on every file, and JSDoc on every public export. See CONTRIBUTING.md.


API reference

Every public export ships JSDoc — hover any symbol in your editor for a summary, @param list, @returns shape, and @example block on the primary entry points. Start with the subpath entry point:

  • jsonparseJson, formatJson, validateJson, diffJson, jsonDeepEqual, flattenJson, mutate
  • jwtdecodeJwt
  • queryrunQuery, pathToJsonPath, pathToJmesPath
  • convert — yaml · csv · typescript · zod · pydantic · json-schema (both directions)
  • cryptoderiveMasterKey, encryptSnippet, decryptSnippet, recovery flow
  • shareencodeShare, decodeShareAuto, password-protected variants
  • typesResult<T, E>, ok, err

Versioning

Semver. The current major is 1. Breaking changes — exports removed, return-shape changes — only land on a major bump.

Contributing

See CONTRIBUTING.md. pnpm validate must be green before any PR (format + lint + typecheck + 95 % coverage + build).

License

MIT © JSONZen.