{"id":48277,"library":"json-schema-it","title":"json-schema-it","description":"json-schema-it is a lightweight, type-safe JSON Schema generator for JavaScript/TypeScript (v1.2.24, stable). It converts JavaScript values—primitives, objects, and arrays—into JSON Schema objects without custom options or configuration. It ships TypeScript types and supports both ESM and CJS. Key differentiators: zero dependencies, no configuration, and strictly clamps to standard JSON typeof types (e.g., null is not allowed). It throws on undefined, Symbol, and BigInt. Released via Release Please on GitHub with community maintenance under the Braze organization. Suitable for validation, documentation generation, and API schema inference.","status":"active","version":"1.2.24","language":"javascript","source_language":"en","source_url":"https://github.com/braze-community/json-schema-it","tags":["javascript","json-schema","json","schema","js","document","typescript"],"install":[{"cmd":"npm install json-schema-it","lang":"bash","label":"npm"},{"cmd":"yarn add json-schema-it","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-schema-it","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import does not work; must use named import.","wrong":"import generateSchema from 'json-schema-it'","symbol":"generateSchema","correct":"import { generateSchema } from 'json-schema-it'"},{"note":"CJS destructured require is the correct pattern.","symbol":"generateSchema","correct":"const { generateSchema } = require('json-schema-it')"},{"note":"Do not assign the whole module; destructure the export.","wrong":"const generateSchema = require('json-schema-it')","symbol":"generateSchema","correct":"import { generateSchema } from 'json-schema-it'"}],"quickstart":{"code":"import { generateSchema } from 'json-schema-it';\n\nconst schema = generateSchema({\n  productId: 1,\n  productName: 'A green door',\n  price: 12.5,\n  tags: ['home', 'green'],\n});\n\nconsole.log(JSON.stringify(schema, null, 2));\n// Output:\n// {\n//   \"type\": \"object\",\n//   \"properties\": {\n//     \"productId\": { \"type\": \"integer\" },\n//     \"productName\": { \"type\": \"string\" },\n//     \"price\": { \"type\": \"number\" },\n//     \"tags\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n//   }\n// }","lang":"typescript","description":"Demonstrates generating a JSON Schema from a JavaScript object with various types."},"warnings":[{"fix":"Pass only valid JSON values (string, number, boolean, object, array). Use e.g. generateSchema({key: null}) for objects containing null.","message":"Null values are not valid JSON; passing null will throw a TypeError.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Exclude undefined from input or use a default value.","message":"Undefined values are not allowed; generateSchema(undefined) throws.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"N/A","message":"No deprecated features known.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure consistency or use a different schema library for mixed arrays.","message":"Array items must all be of the same type; mix types yield the type of the first item.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'allow':67 'api':94 'array':29 'bigint':74 'braze':86 'cjs':48 'clamp':57 'communiti':82 'configur':38,54 'convert':23 'custom':35 'depend':52 'differenti':50 'document':91,104 'e.g':63 'esm':46 'generat':17,92 'github':80 'infer':96 'javascript':24,97 'javascript/typescript':19 'js':103 'json':2,6,15,31,60,99,101 'json-schema':98 'json-schema-it':1,5 'key':49 'lightweight':11 'mainten':83 'null':64 'object':27,33 'option':36 'organ':87 'pleas':78 'primit':26 'releas':75,77 'safe':14 'schema':3,7,16,32,95,100,102 'ship':40 'stabl':21 'standard':59 'strict':56 'suitabl':88 'support':44 'symbol':72 'throw':69 'type':13,42,62 'type-saf':12 'typeof':61 'typescript':41,105 'undefin':71 'v1.2.24':20 'valid':90 'valu':25 'via':76 'without':34 'zero':51","created_at":"2026-06-07T16:55:48.145363+00:00","updated_at":"2026-06-07T16:55:48.145363+00:00","problems":[{"fix":"Do not pass undefined; use null or exclude the property.","cause":"generateSchema received undefined directly or within an object property.","error":"TypeError: Invalid JSON value: undefined"},{"fix":"Convert Symbol to string before passing.","cause":"generateSchema received a Symbol, which is not valid JSON.","error":"TypeError: Invalid JSON value: Symbol()"},{"fix":"Convert BigInt to number or string.","cause":"generateSchema received a BigInt, which is not valid JSON.","error":"TypeError: Invalid JSON value: 123n"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/braze-community/json-schema-it#readme","github":"https://github.com/braze-community/json-schema-it","docs":null,"changelog":null,"pypi":null,"npm":"json-schema-it","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}