{"id":48285,"library":"json-schema-empty","title":"json-schema-empty","description":"Generates minimal, deterministic data from a JSON Schema. Version 1.1.1 is current. The library fills values that fit the structure of the schema (e.g., empty strings, zeros, empty arrays) rather than random data. It supports JSON Schema draft-04, including $ref, oneOf, anyOf, allOf, and enum. Unlike data generators like json-schema-faker, it prioritizes simplicity and determinism for use cases like form defaults or test fixtures.","status":"active","version":"1.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/romeovs/json-schema-empty","tags":["javascript"],"install":[{"cmd":"npm install json-schema-empty","lang":"bash","label":"npm"},{"cmd":"yarn add json-schema-empty","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-schema-empty","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import only. No named export.","wrong":"const empty = require('json-schema-empty')","symbol":"empty","correct":"import empty from 'json-schema-empty'"}],"quickstart":{"code":"import empty from 'json-schema-empty';\n\nconst schema = {\n  type: 'object',\n  properties: {\n    name: { type: 'string' },\n    age: { type: 'integer', minimum: 0, maximum: 120 },\n    tags: { type: 'array', items: { type: 'string' }, minItems: 1 }\n  },\n  required: ['name', 'age']\n};\n\nconst result = empty(schema);\nconsole.log(result);\n// { name: '', age: 0, tags: [] }","lang":"typescript","description":"Shows how to generate empty or minimal data based on a JSON schema with required fields and constraints."},"warnings":[{"fix":"Do not rely on generated strings to satisfy constraints. Handle string validation separately if needed.","message":"String schema always returns empty string, even if minLength > 0 or pattern is specified.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If you need a specific array length, set minItems to the desired length. maxItems has no effect.","message":"Array schema ignores maxItems and always returns the shortest array (empty unless minItems is set).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"To include optional properties, list them in required or merge with a required array.","message":"Object schema only includes keys in 'required' array; other properties are omitted even if present in schema.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use for form defaults or structural stubs, not for strict schema validation.","message":"Generated data may not be valid according to the schema due to unenforceable constraints (e.g., pattern, maxLength).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'-04':43 '1.1.1':14 'allof':48 'anyof':47 'array':33 'case':66 'current':16 'data':8,37,52 'default':69 'determin':63 'determinist':7 'draft':42 'e.g':28 'empti':4,29,32 'enum':50 'faker':58 'fill':19 'fit':22 'fixtur':72 'form':68 'generat':5,53 'includ':44 'javascript':73 'json':2,11,40,56 'json-schema-empti':1 'json-schema-fak':55 'librari':18 'like':54,67 'minim':6 'oneof':46 'priorit':60 'random':36 'rather':34 'ref':45 'schema':3,12,27,41,57 'simplic':61 'string':30 'structur':24 'support':39 'test':71 'unlik':51 'use':65 'valu':20 'version':13 'zero':31","created_at":"2026-06-07T16:55:50.321025+00:00","updated_at":"2026-06-07T16:55:50.321025+00:00","problems":[{"fix":"Use import empty from 'json-schema-empty' in ESM environment or transpile with bundler.","cause":"Using CommonJS require with CJS build not available; npm package exports ESM only.","error":"TypeError: empty is not a function"},{"fix":"Ensure schema argument is a valid object with a 'type' property (or $ref).","cause":"Passing an empty object or null as schema instead of a valid JSON Schema object.","error":"Cannot read properties of undefined (reading 'type')"}],"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/romeovs/json-schema-empty#readme","github":"https://github.com/romeovs/json-schema-empty","docs":null,"changelog":null,"pypi":null,"npm":"json-schema-empty","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}}