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

mkschema

v0.1.0

Published

Generate a JSON Schema from sample JSON — merge multiple samples (or NDJSON) with type + format inference and required-key detection. Zero dependencies.

Downloads

55

Readme

mkschema

Generate a JSON Schema from real JSON — and feed it more than one sample. You have an API response, a config, a pile of log records, and you want a JSON Schema for validation, docs, or contract tests. Hand-writing it is tedious; most generators take a single example and over-fit it — every field marked required, types pinned to whatever that one record happened to contain. mkschema merges many samples: a field in every sample is required, a field in only some is optional, and differing types are unioned. Zero dependencies, no network.

$ printf '{"id":1,"name":"Ada","age":30}\n{"id":2,"age":30.5}\n' | npx mkschema --ndjson -

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "age":  { "type": "number" },        // 30 and 30.5 unioned to number
    "id":   { "type": "integer" },
    "name": { "type": "string" }
  },
  "required": ["age", "id"]               // name was missing from the 2nd sample, so it's optional
}

Usage

mkschema sample.json                 # infer from one file
mkschema a.json b.json c.json        # merge several samples into one schema
mkschema --ndjson records.ndjson     # one sample per line (logs, exports)
cat response.json | mkschema -        # read a JSON value from stdin
curl -s api/users | mkschema -        # …straight from an API
mkschema users.json --title User --id https://ex.com/user.schema.json

Schema goes to stdout, so redirect it: mkschema data.json > schema.json.

What it infers

  • Typesnull, boolean, integer, number, string, array, object. Numbers are classified by value, so 5.0 is an integer and the Node and Python builds agree.
  • String formatdate-time, date, email, uuid, ipv4, uri (kept only when all samples of a field agree).
  • required — the intersection across samples: a key present in every sample. (One sample ⇒ everything required.)
  • Arraysitems is the merge of all element schemas, so [1, "x"] becomes { "type": ["integer", "string"] }.
  • Unions — a field that is an integer in one sample and a float in another becomes number; genuinely different types become a sorted type array.

Options

| Flag | Effect | |------|--------| | --ndjson <src> | Treat each line of <src> (a file, or - for stdin) as a separate sample | | --title <name> | Set the schema title | | --id <uri> | Set $id | | - | Read one JSON value from stdin | | -v, --version · -h, --help | |

Notes

  • Output is draft 2020-12 JSON Schema, deterministic (properties and required are sorted) so it diffs cleanly in version control.
  • Same tool, two builds. A behavior-equivalent Python build is on PyPI (pip install mkschema); use whichever your stack has.
  • It infers structure, not constraints — add your own minLength, enum, pattern, etc. afterward. mkschema gives you the scaffold from real data.

Exit codes

| Code | Meaning | |------|---------| | 0 | schema written | | 2 | error (no input, invalid JSON, unreadable file) |

License

MIT