How to generate a json schema from an api request payload
- Step 1Collect representative sample payloads — Use the most complete sample API request you have — one that includes all optional fields alongside required fields so the schema captures the full possible shape. A single minimal sample will under-specify optional fields.
- Step 2Generate the schema — Paste the JSON and click Generate. The output is a JSON Schema draft-07 object with $schema, type: object, properties, and required arrays.
- Step 3Refine required vs optional fields — The generator marks all present keys as required by default. Review the schema and move fields that are optional in practice from the required array to optional-only properties.
- Step 4Add format and pattern constraints — Enhance string fields with format constraints: email, uri, date-time, or uuid. Add pattern regex for fields like phone numbers or postal codes. These are not inferred automatically from the sample value.
Frequently asked questions
How do I use the generated schema with AJV in Node.js?+
Install AJV: npm install ajv. Then: const Ajv = require('ajv'); const ajv = new Ajv(); const validate = ajv.compile(schema); const valid = validate(requestBody); if (!valid) console.log(validate.errors). The generated draft-07 schema works with AJV 6.x and AJV 8.x with the draft-07 meta-schema option.
Can I use the schema with OpenAPI 3.0 requestBody?+
Yes. JSON Schema draft-07 is a superset of the OpenAPI Schema Object. Copy the generated schema's properties and required fields into your OpenAPI path's requestBody.content.application/json.schema object. Remove the $schema key as OpenAPI does not include it in inline schemas.
Is the API payload transmitted to JAD Apps?+
No. Schema inference runs entirely in your browser. Sample payloads, request structures, and internal API designs are never transmitted to JAD Apps servers.
Privacy first
Conversion runs locally in your browser. No file is uploaded — only metadata counters are saved for signed-in dashboard stats.