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

@lowdep/json-flatten

v1.0.0

Published

Flatten nested JSON to dot-notation keys and unflatten back — lossless round-trip, zero dependencies

Readme

json-flatten (CLI)

Zero dependencies Node License: MIT Platform

Flatten nested JSON into dot-notation keys — and unflatten it back. The transform is lossless: flatten then unflatten returns the original. Zero dependencies.

Handy for diffing configs line-by-line, generating env vars from nested settings, flattening i18n message files, or feeding nested JSON into tabular tools.

Installs the json-flatten command. (npm package name is json-flatten-cli.)


Install

npm install -g json-flatten-cli

Or without installing:

npx json-flatten-cli config.json

Usage

json-flatten config.json              # Flatten
json-flatten flat.json --unflatten    # Rebuild nested JSON
json-flatten config.json -d /         # Use "/" as the separator
json-flatten settings.json --no-arrays
cat nested.json | json-flatten - --compact

Example

config.json:

{
  "db": { "host": "localhost", "port": 5432 },
  "features": ["auth", "billing"],
  "log": { "level": "info" }
}

json-flatten config.json:

{
  "db.host": "localhost",
  "db.port": 5432,
  "features.0": "auth",
  "features.1": "billing",
  "log.level": "info"
}

Reverse it with --unflatten and you get the original structure back — arrays included (numeric keys become array indices).


Why Flatten?

| Use case | Benefit | |---|---| | Config diffs | Flat keys diff cleanly line-by-line (great with json-diff) | | Env vars | db.hostDB_HOST is a short hop | | i18n files | home.title.welcome keys are easy to grep and sort | | Tabular export | One flat object = one CSV row | | Feature flags | Flat dotted keys map to many flag systems |


Round-Trip Guarantee

json-flatten data.json | json-flatten - --unflatten
# → structurally identical to data.json

Keys that contain the delimiter literally are backslash-escaped on flatten and restored on unflatten, so no information is lost.


Options

| Flag | Default | Description | |---|---|---| | -u, --unflatten | off | Reverse: flat keys → nested | | -d, --delimiter <d> | . | Key separator | | --max-depth <n> | ∞ | Stop flattening past this depth | | --no-arrays | off | Keep arrays intact (don't index in) | | -o, --out <file> | — | Write to a file | | --compact | off | Single-line JSON |


License

MIT


Keywords

flatten json · unflatten json · dot notation · nested json · json flattener · flat keys · json transform · config flatten · zero dependencies · cli


Built to solve, shared to help — Rushabh Shah 🛠️✨

One of 40+ zero-dependency developer CLI tools — no node_modules, ever.