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

jsontool-cli

v1.0.0

Published

Powerful JSON processing CLI: format, validate, minify, query, diff, CSV conversion. Zero dependencies.

Downloads

122

Readme

@mazhu/jsontool

Powerful JSON processing CLI — zero dependencies, pure Node.js

npm version

Install

npm install -g @mazhu/jsontool

Commands

| Command | Alias | Description | |---------|-------|-------------| | fmt | format, pretty | Format / pretty-print JSON | | min | minify, compress | Minify JSON | | val | validate, check | Validate JSON syntax | | jq | query | Query with JSONPath | | diff | compare | Compare two JSON files | | csv2json | csv-to-json | Convert CSV to JSON | | json2csv | json-to-csv | Convert JSON array to CSV |

Usage

Format JSON

# Format a file
jsontool fmt data.json

# Format from pipe
echo '{"a":1}' | jsontool fmt

# Custom indent
jsontool fmt data.json --indent 4

# Sort keys alphabetically
jsontool fmt data.json --sort

Minify JSON

jsontool min data.json
echo '{"a": 1, "b": 2}' | jsontool min

Validate JSON

jsontool val data.json
echo '{"valid": true}' | jsontool val

JSONPath Query

# Access nested property
jsontool jq '$.store.book[0].title' data.json

# All array elements
jsontool jq '$.users[*].name' data.json

# Array slice
jsontool jq '$.items[0:3]' data.json

# Recursive descent (find all 'email' keys at any depth)
jsontool jq '$..email' data.json

Supported JSONPath features:

  • $.key — child access
  • $[n] — array index
  • $[*] — all elements
  • $[start:end] — array slice
  • $..key — recursive descent

Diff JSON Files

# Compare two files
jsontool diff a.json b.json

# Colored output
jsontool diff a.json b.json --color

Output shows added (+), removed (-), and changed (~) fields with paths.

CSV → JSON

# Convert CSV file
jsontool csv2json data.csv

# From pipe
cat data.csv | jsontool csv2json

# Custom delimiter
jsontool csv2json data.csv -d ";"

# No header row
jsontool csv2json data.csv --no-header

JSON → CSV

# Convert JSON array to CSV
jsontool json2csv data.json

# Skip header
jsontool json2csv data.json --no-header

# Custom delimiter
jsontool json2csv data.json -d "\t"

Pipe Support

All commands support reading from stdin:

curl -s https://api.example.com/data | jsontool fmt
cat data.csv | jsontool csv2json | jsontool jq '$[0]'
cat a.json | jsontool min > a.min.json

Library Usage

const jsontool = require('@mazhu/jsontool');

// Use programmatically
const { parseCSV, escapeCSV, compare } = jsontool;

Features

  • ✅ Zero dependencies
  • ✅ Pipe / stdin support
  • ✅ Colored diff output
  • ✅ Smart type detection in CSV conversion
  • ✅ Key sorting option
  • ✅ Custom indentation
  • ✅ Custom CSV delimiters
  • ✅ Quoted field handling in CSV
  • ✅ Lightweight and fast

License

MIT © 迈克王