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-schema-gen

v1.0.0

Published

Generate JSON Schema (draft-07) from sample JSON data — format detection, multi-sample merging, zero dependencies

Readme

json-schema-gen

Zero dependencies Node License: MIT Platform

Generate JSON Schema (draft-07) from sample JSON data. Detects string formats (email, URI, UUID, date-time), merges schemas from multiple samples, and outputs a clean schema ready for validation. Zero dependencies.

Like quicktype but needs no installation — and genson (Python) or online tools are overkill when you just need a schema.


Install

npm install -g json-schema-gen

Or without installing:

npx json-schema-gen data.json

Example

Given user.json:

{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "name": "Alice Johnson",
  "email": "[email protected]",
  "age": 32,
  "active": true,
  "createdAt": "2024-01-15T09:30:00Z",
  "tags": ["admin", "user"],
  "address": {
    "street": "123 Main St",
    "city": "Springfield",
    "zip": "62701"
  }
}

Running json-schema-gen user.json --required outputs:

{
  "$schema": "https://json-schema.org/draft-07/schema",
  "type": "object",
  "properties": {
    "id":        { "type": "string", "format": "uuid" },
    "name":      { "type": "string" },
    "email":     { "type": "string", "format": "email" },
    "age":       { "type": "integer" },
    "active":    { "type": "boolean" },
    "createdAt": { "type": "string", "format": "date-time" },
    "tags":      { "type": "array", "items": { "type": "string" } },
    "address": {
      "type": "object",
      "properties": {
        "street": { "type": "string" },
        "city":   { "type": "string" },
        "zip":    { "type": "string" }
      },
      "required": ["street", "city", "zip"],
      "additionalProperties": false
    }
  },
  "required": ["id", "name", "email", "age", "active", "createdAt", "tags", "address"],
  "additionalProperties": false
}

Usage

json-schema-gen user.json                            # Basic schema
json-schema-gen user.json --required                 # Mark all fields as required
json-schema-gen user.json --title "User" --id "/schemas/user"
json-schema-gen user.json --out schema.json          # Write to file
json-schema-gen s1.json s2.json s3.json              # Merge from multiple samples
cat data.json | json-schema-gen -                    # Read from stdin

Detected Formats

| Format | Example | |---|---| | date-time | "2024-01-15T09:30:00Z" | | date | "2024-01-15" | | time | "09:30:00" | | email | "[email protected]" | | uri | "https://example.com" | | uuid | "a1b2c3d4-e5f6-7890-abcd-ef1234567890" | | ipv4 | "192.168.1.1" |


Multi-Sample Merging

Pass multiple JSON files to infer a schema that covers all of them. Fields present in only some samples will not be marked required:

json-schema-gen user1.json user2.json user3.json

Options

| Flag | Description | |---|---| | --required | Mark all non-null fields as required | | --examples | Include example values for string fields | | --title <name> | Add title to the schema | | --id <uri> | Add $id to the schema | | --out <file> | Write output to a file |


License

MIT


Keywords

json schema generator · json to schema · quicktype alternative · genson alternative · infer schema · draft-07 · generate schema · json schema · zero dependencies · cli


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

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