Socket
Book a DemoInstallSign in
Socket

json-schema-it

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-it

JSON Schema generator.

latest
Source
npmnpm
Version
1.2.18
Version published
Weekly downloads
136
-24.86%
Maintainers
1
Weekly downloads
 
Created
Source

json-schema-it

NPM

NPM version build codecov

JSON Schema generator.

Quick Start

import { generateSchema } from 'json-schema-it';

generateSchema(42); // { type: 'integer' }

Installation

NPM:

npm install json-schema-it

Yarn:

yarn add json-schema-it

Usage

ES Modules:

import { generateSchema } from 'json-schema-it';

CommonJS:

const { generateSchema } = require('json-schema-it');

Generate JSON Schema:

generateSchema({
  productId: 1,
  productName: 'A green door',
  price: 12.5,
  tags: ['home', 'green'],
});

Output:

{
  type: 'object',
  properties: {
    productId: { type: 'integer' },
    productName: { type: 'string' },
    price: { type: 'number' },
    tags: { type: 'array', items: { type: 'string' } },
  },
}

An error will be thrown for an invalid JSON value:

generateSchema(undefined); // Uncaught TypeError: Invalid JSON value: undefined

Release

Release is automated with Release Please.

License

MIT

Keywords

json-schema

FAQs

Package last updated on 04 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts