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

jsongo

v0.7.0

Published

Like MongoDB, except stores data in git-friendly flat json files

Downloads

16

Readme

jsongo

Jsongo is a simple, lightweight, yet flexible database system.

To install the library:

$ yarn add jsongo

To use the jsongo tool:

$ npx jsongo

To make jsongo tool globally available:

$ npm install --global jsongo

Backgrounder

Jsongo prioritizes human-friendliness and an obvious data format that's of archival quality (its data should be able to be easily read far into the future past when JSON and Git are legacy technologies).

It consists of a data format, a code library, and a CLI tool.

Pros:

  • Freeform Record Format
  • Human (Developer) Interaction Prioritized
  • Highly Semantic
    • Simple and obvious named data files
    • Textually explorable
    • Archival Quality
    • Easily utilize semantic "callsign" primary keys
  • Version Control Friendly
  • Version Control Agnostic

Cons:

  • Freeform Record Format
  • Inefficient
    • Slow to load
    • Slow to search
    • Large on Disk (uncompressed)
    • Large in Memory
  • Bad at long-form text, dates, and blobs
  • Though intended for direct editing, JSON Extraneous Comma Syntax Error is irritating
  • Easy to Add Inconsistent Information (no constraints mechanism)
  • No concurrent writing (reading is fine)
  • No change notifications
  • Lossily sorts Record's keys when saved

Data Format

Jsongo's data format is basically the same as MongoDB's semantic data model:

Database <->> Collection <->> Document

On-disk, the database is represented as a directory and the collections as JSON files:

database/
└─collection.json

In general it's a bad idea to put non-Jsongo *.json files in a Jsongo database directory. The code assumes that all JSON files in a directory is part of a database.

A collection has an array of Documents.

The Document format is a superset of JSON:

  1. On-disk it's pretty-printed with 2-space indent (JSON.stringify(, null, 2)).
  2. Records are sorted by their _id.
  3. Object keys are sorted.

Sorting Object keys makes Jsongo even slower, but greatly aids in creating simple diffs and merging changes.

Keys are sorted with Array.prototype.sort() using the standard compareFunction (a custom one isn't supplied).

Relations

When a document has a key that ends in _id, it's interpreted to mean a foreign key.

Consider person.json collection:

{
  "Homer": {
    "family_id": "Simpson"
  },
  "Marge": {
    "family_id": "Simpson"
  }
}

This implies a family.json with at least the following data:

{
  "Simpson": {}
}

jsongo fsck will follow such relations and ensure they all exist.

Library

Jsongo offers two database drivers:

  • file system (using .json files)
  • in-memory (using POJOs at runtime)

In Node, you can use either driver. For example:

import { fsDB } from "jsongo";
const db = fsDB("./path/to/cartoon");
const simpsonFamilyMembers = db.person.find({ family_id: "Simpson" }).all();
console.log(simpsonFamilyMembers);
[
  {
    "_id": "Bart",
    "family_id": "Simpson"
  },
  {
    "_id": "Homer",
    "family_id": "Simpson"
  },
  {
    "_id": "Lisa",
    "family_id": "Simpson"
  },
  {
    "_id": "Maggie",
    "family_id": "Simpson"
  },
  {
    "_id": "Marge",
    "family_id": "Simpson"
  }
]

In browsers, use the memory driver:

import { memDB } from "jsongo";
const db = memDB();

For more examples including project configuration, see /examples.

CLI Tool

Sorted by most commonly used:

jsongo fmt --dataDir <path>

Reads the collection json files, inserting an _id if the record doesn't already have one and pretty-printing the output.

jsongo fsck --dataDir <path>

Checks consistency of entire database.

jsongo ls --dataDir <path>

Lists names of the database collections.

jsongo rewrite-id --dataDir <path> --collection <name> --oldID <object_id> --newID <object_id>

Makes it easy to replace an automatically generated _id with a semantic one.

jsongo rewrite-id --dataDir data --collection person --oldID 5e58083b2459f248bcdc2032 --newID fflintstone

jsongo objectid --times [number]

When you need to generate a new ObjectID.

$ jsongo objectid
5e78113ce16c4b07694a2bf1

$ jsongo objectid --times 3
5f53202fe9f96f47744b482b
5f53202fe9f96f47744b482c
5f53202fe9f96f47744b482d

jsongo eval --dataDir <path> --code <string>

Runs JavaScript code with access to a local db var.

$ jsongo eval --code "db.person.find({}).all()"
[ { _id: '5f531ca259e05c432b15aa89', name: 'Jeff' } ]