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

v1.0.0

Published

Generate JSON Schema (draft-07) from sample JSON data. Handles nested objects, arrays, type detection, and schema merging. CLI tool.

Readme

json-to-schema

npm version License: MIT

Generate JSON Schema (draft-07) from sample JSON data. It handles nested objects, arrays, type detection, and can merge multiple samples into one schema.

Install

npm install -g @lxgicstudios/json-to-schema

Or run directly:

npx @lxgicstudios/json-to-schema data.json

Features

  • Draft-07 output - Generates valid JSON Schema draft-07
  • Type inference - Detects string, number, integer, boolean, null, object, array
  • Format detection - Recognizes date-time, email, URI, UUID, IPv4, IPv6
  • Schema merging - Combine multiple samples into one schema
  • Required fields - Mark all fields as required with one flag
  • Nested support - Handles deeply nested objects and arrays
  • JSONL support - Process multiple JSON objects per file
  • Pipe-friendly - Works great with stdin/stdout
  • Colorized output - Pretty terminal output with syntax highlighting
  • Zero dependencies - Built with Node.js builtins only

Usage

# From a file
json-to-schema data.json

# From stdin
echo '{"name":"John","age":30,"email":"[email protected]"}' | json-to-schema

# Merge multiple samples
json-to-schema --merge -f sample1.json -f sample2.json

# All fields required
json-to-schema --required data.json

# With title and description
json-to-schema --title "User" --description "A user object" data.json

# Pipe from an API
curl -s https://api.example.com/users/1 | json-to-schema --title "User"

# Compact output
json-to-schema --compact data.json

Options

| Option | Description | Default | |--------|-------------|---------| | -f, --file <path> | Input JSON file (repeatable) | - | | --merge | Merge schemas from multiple samples | false | | --required | Mark all fields as required | false | | --title <title> | Schema title | - | | --description <desc> | Schema description | - | | --additional | Allow additional properties | false | | --no-format | Skip format detection | false | | --compact | No indentation in output | false | | --help | Show help | - |

Example Output

Input:

{
  "id": 1,
  "name": "John Doe",
  "email": "[email protected]",
  "active": true,
  "tags": ["admin", "user"]
}

Output:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string" },
    "email": { "type": "string", "format": "email" },
    "active": { "type": "boolean" },
    "tags": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "additionalProperties": false
}

Built by LXGIC Studios

GitHub | Twitter