Tool overview
What is a Structured Output / JSON Schema Generator?
This tool infers JSON Schema from example payloads so LLM tool calling and structured outputs have a strict contract.
Why use this Structured Output Generator?
Turn sample JSON into schemas for OpenAI-style function calling without uploading proprietary payload shapes.
Key Features
Example-to-schema inference, strictness controls, copy-ready JSON Schema, and client-side processing.
How to Use
Follow these steps to get accurate results from the tool interface above.
- Paste a representative JSON example of your LLM tool response or function arguments into the left panel.
- Omit keys that should be optional — only keys present in the example become required properties.
- Enable Strict objects to emit additionalProperties: false on every object node — recommended for OpenAI structured outputs.
- Optionally set a Schema title for OpenAPI or tool registry documentation.
- Review the generated JSON Schema draft 2020-12 output on the right panel.
- If an array shows items: {}, add at least one representative element and regenerate.
- Copy the schema into response_format, tool parameters, or your agent configuration.
- Iterate on the example when types look wrong; hand-edit enums or oneOf after generation when needed.
Structured Output Generator — Complete Guide & Use Cases
Authoritative walkthrough: draft 2020-12 inference, strict additionalProperties, OpenAI and tool-parameter use cases, empty-array fixes, and optionality by omission — aligned with the generator above.
Structured Output Generator guide — start here
This page is the canonical guide to inferring JSON Schema draft 2020-12 from example payloads with DevUtilities’ Structured Output Generator. Paste a representative JSON example above while you read, or jump to a topic below. Inference runs entirely in your browser.
What Structured Output Generator does
Structured Output Generator turns a sample JSON value into a draft 2020-12 JSON Schema. It maps strings, numbers, integers, booleans, nulls, arrays, and nested objects — and can emit additionalProperties: false on every object when strict mode is on (recommended for OpenAI structured outputs and strict tool calling).
What you get
- JSON Schema with $schema set to draft 2020-12
- Optional schema title and description for registries / OpenAPI notes
- Strict mode: additionalProperties: false on every object node
- Required arrays built from keys present in the example (omit keys to keep them optional)
- Integer vs number inference from whole vs decimal sample values
- Copy-ready schema for response_format, tool parameters, or agent configs
Use this tool when
- You have a golden example response and need a schema fast
- You are wiring OpenAI structured outputs or function-calling parameters
- You want strict closed objects without hand-writing nested additionalProperties
- You need to iterate: tweak the example, regenerate, paste into the agent
Prefer a related tool when
- You need schemas + MCP + prompts together → AI Agent Builder
- You only need to lint mcpServers JSON → MCP Validator
- You need token cost of a large schema → LLM Token Counter
How example JSON maps to schema types
Inference walks the parsed JSON tree. Input must be strict JSON — unquoted keys fail before schema generation starts.
Type mapping
| Example value | Inferred type | Notes |
|---|---|---|
| "ok" | string | Any JSON string |
| 42 | integer | Whole numbers only |
| 42.5 | number | Any non-integer number |
| true | boolean | JSON true/false |
| null | null | Prefer omission for optional strings |
| [] | array + items: {} | Add one sample element |
| { "a": 1 } | object | Keys become required; strict adds additionalProperties: false |
Arrays take the type of the first element only. Mixed-type arrays need hand-edits (oneOf) after generation.
Step-by-step: example → draft 2020-12 schema
First-time walkthrough for an OpenAI-ready response schema.
- Paste a representative JSON example of the model output or tool arguments into the left panel.
- Omit keys that should be optional in production — only present keys become required.
- Enable Strict objects so every object emits additionalProperties: false.
- Optionally set a Schema title for documentation or tool registries.
- Review the draft 2020-12 schema on the right; fix the example if types look wrong.
- If an array shows items: {}, add at least one representative element and regenerate.
- Copy the schema into response_format, tools[].function.parameters, or your agent config.
- Cross-check OpenAI structured-output limits (nesting, unsupported keywords) before deploy.
Use case: OpenAI structured outputs
Problem: you need a closed JSON Schema for OpenAI structured outputs and do not want to hand-author nested additionalProperties: false.
How this tool helps
- Paste a complete example of the expected response object.
- Turn on Strict objects.
- Copy the generated schema into the API response_format / json_schema config.
- Verify nesting depth and types against OpenAI’s structured outputs docs.
Outcome: a draft 2020-12 schema with closed objects ready for structured output calls.
Use case: function-calling tool parameters
Problem: function-calling tool parameters are easier to design from a sample args object than from an empty schema editor.
How this tool helps
- Write one realistic tool-arguments JSON object (names, ids, filters).
- Generate with strict mode for OpenAI strict tool calling.
- Paste into tools[].function.parameters (or export via AI Agent Builder for multi-tool agents).
- Align the system prompt tool names with the schema property names.
Outcome: parameters that match real calls and reject undeclared keys when strict.
Use case: optional fields by omission
Problem: every key in the example becomes required, but some fields should be optional at runtime.
How this tool helps
- Build the example with only required keys present.
- Generate the schema — omitted keys never appear in required.
- If you need a property declared but not required, add it manually after generation or regenerate from a fuller example and edit required.
- Avoid null samples for fields that should be strings — null infers type null.
Outcome: optional fields modeled by omission, matching how the generator builds required arrays.
Use case: structured JSON classifier
Problem: a sentiment or routing classifier must return one JSON object the app can parse reliably.
How this tool helps
- Paste an example like { "label": "positive", "confidence": 0.92, "rationale": "…" }.
- Enable strict mode so extra keys cannot slip through.
- Copy the schema into structured-output or Agent Builder structured-response mode.
- Keep enum unions as a manual follow-up if labels must be a fixed set.
Outcome: a single closed response schema for classifiers and extractors.
Strict mode and additionalProperties: false
Strict mode walks every object node and sets additionalProperties: false. That matches OpenAI structured outputs and strict tool calling expectations for closed objects.
- Leave strict on for production exports
- Turn it off only while exploring open shapes, then re-enable before copy
- Every expected key must appear in the example — undeclared keys will be rejected at validation time
- Nested objects inherit the same rule recursively
Empty array pitfall — items: {}
Empty arrays cannot reveal an item type. The generator emits { "type": "array", "items": {} }, which is too loose for structured outputs.
- Always include at least one representative array element in the example
- Item schema is inferred from the first element only
- For heterogeneous arrays, hand-edit oneOf after generation
- Regenerate after fixing the example rather than only patching items by hand when possible
Fix: invalid JSON input
Generation fails with invalid JSON.
Why it happens
The input is not strict JSON — trailing commas, single quotes, or unquoted keys are common when pasting from TypeScript or Python.
Diagnose
The left panel cannot parse; no schema appears on the right.
Fixes
- Convert to double-quoted keys and strings.
- Remove trailing commas and comments.
- Validate with a JSON linter, then paste again.
Fix: array items inferred as {}
Schema shows "items": {} for an array.
Why it happens
The example array was empty, so no element type could be inferred.
Diagnose
Find array fields in the example that are [].
Fixes
- Add one realistic element that matches production shape.
- Regenerate the schema.
- Confirm items now has a concrete type or nested object.
Mixed-type arrays still need manual oneOf after a good first-element inference.
Fix: optional field marked required
A field that should be optional is listed under required.
Why it happens
Every key present in the example is added to required. Optional fields must be omitted from the sample.
Diagnose
Compare the example keys to the required array in the output schema.
Fixes
- Remove optional keys from the example and regenerate.
- Or hand-edit the schema to drop keys from required after generation.
- Do not use null as a stand-in for “missing string” — that infers type null.
Schema inference best practices
- Design from a golden example that matches production, not a toy stub
- Keep strict mode on for OpenAI structured outputs and strict tools
- Model optionality by omission, not null placeholders
- Never ship empty arrays in the example — seed one item
- Hand-edit enums and oneOf; this tool does not infer them automatically
- Minify large schemas in LLM Token Counter before budgeting prompts
- Use AI Agent Builder when the schema is one piece of a full agent export
Frequently Asked Questions
Expandable answers for common debugging bottlenecks and data privacy questions.
Related tools
Explore other related utilities that complement this tool.
Official Documentation & References
Authoritative specifications and platform documentation for this utility.