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

@lxgicstudios/json-flatten

v1.0.0

Published

Flatten nested JSON to dot-notation key-value pairs and unflatten back. Custom delimiters, path filtering, and pipe-friendly CLI.

Readme

json-flatten

npm version License: MIT

Flatten nested JSON to dot-notation key-value pairs. Also unflatten back to nested structures. Supports custom delimiters, path filtering, and plays nice with pipes.

Install

npm install -g @lxgicstudios/json-flatten

Or run directly:

npx @lxgicstudios/json-flatten data.json

Features

  • Flatten - Nested JSON to flat dot-notation pairs
  • Unflatten - Reverse operation, back to nested
  • Custom delimiters - Use /, _, or whatever you want
  • Path filtering - Match paths with * and ** wildcards
  • Keys only / Values only - Extract just what you need
  • Stats mode - Count keys, max depth, type breakdown
  • Pipe-friendly - Reads stdin, writes stdout
  • JSON output - Get the flat object as JSON
  • Colorized display - Pretty key=value output in terminal
  • Zero dependencies - Built with Node.js builtins only

Usage

# Flatten a JSON file
json-flatten data.json

# From stdin
echo '{"user":{"name":"John","address":{"city":"NYC"}}}' | json-flatten
# Output:
# user.name = "John"
# user.address.city = "NYC"

# Unflatten back
echo '{"user.name":"John","user.address.city":"NYC"}' | json-flatten --unflatten

# Custom delimiter
json-flatten -d '/' data.json
# Output: user/name = "John"

# Filter paths
json-flatten --filter 'user.*' data.json

# Deep wildcard filter
json-flatten --filter '**.name' data.json

# JSON output
json-flatten --json data.json

# Keys only (great for piping to sort, grep, etc)
json-flatten --keys-only data.json | sort

# Count total keys
json-flatten --count data.json

# Stats
json-flatten --stats data.json

Options

| Option | Description | Default | |--------|-------------|---------| | -f, --file <path> | Input JSON file | - | | -u, --unflatten | Unflatten (reverse operation) | false | | -d, --delimiter <char> | Key separator | . | | --filter <pattern> | Filter by path pattern (*, **) | - | | --json | Output as JSON object | false | | --stats | Show statistics | false | | --compact | Compact JSON output | false | | --keys-only | Print only keys | false | | --values-only | Print only values | false | | --count | Print number of keys | false | | --help | Show help | - |

Example

Input (data.json):

{
  "user": {
    "name": "Jane",
    "age": 28,
    "address": {
      "street": "123 Main St",
      "city": "Portland"
    },
    "tags": ["dev", "admin"]
  }
}

Flattened output:

user.name = "Jane"
user.age = 28
user.address.street = "123 Main St"
user.address.city = "Portland"
user.tags.0 = "dev"
user.tags.1 = "admin"

Built by LXGIC Studios

GitHub | Twitter