CruxDevCruxDev Tools Prompts
ai Utility • Zero-Server Privacy • 100% Client-Side

JSON Schema Generator (Strict)

Turn sample JSON into an LLM strict-mode JSON Schema - every field required, additionalProperties locked.

Overview

Turn a sample JSON payload into a strict-mode JSON Schema ready for structured LLM outputs. Paste one realistic example of the data you want a model to produce, and the generator infers the schema with every field required and additionalProperties locked to false - the two rules OpenAI's Structured Outputs mode enforces. Runs entirely in your browser.

How It Works

Paste a single sample JSON object into the left pane. The inferred schema appears on the right as formatted, copyable JSON. If the sample is not valid JSON, the exact parse error is shown instead of a schema, so you can fix the input. The generator handles nested objects, arrays, strings, integers, floats and booleans, and applies the strict-mode rules at every level of nesting, not just the root. There is no configuration step: strictness is the point of the tool.

Step-by-Step Usage Guide

  1. Paste one realistic JSON example of the output you want.
  2. Read the inferred schema in the right pane.
  3. Fix any JSON parse error shown for invalid input.
  4. Copy the schema into your API call's response_format or tool definition.

Technical Specifications & Standards

Inference walks the sample value by value: whole numbers become integer types, decimals become number, booleans and strings map directly, null becomes a string (there is no safe way to guess a type from null), and arrays take the type of their first element - an empty array produces an items schema with no constraint. Every object, at every depth, gets all of its keys listed in required and additionalProperties set to false. Those two constraints are exactly what OpenAI Structured Outputs demands: the API rejects strict schemas that omit fields from required or leave additionalProperties unset, because the constrained-decoding machinery needs a fully determined shape. The trade-off of inferring from one example is visible in the result: a field that happened to hold an integer is typed integer forever, optional fields become mandatory, and no enums, formats or descriptions are invented. Edit the schema afterwards if any field is genuinely optional - strict mode has no optional fields by design.

Targeted Use Cases

  • Preparing a response_format schema for extraction tasks like invoices or contacts.
  • Defining a tool-calling parameter schema that will not be rejected by the API.
  • Locking down the shape of model output before wiring it into a typed application.
  • Teaching the two strict-mode rules with a before-and-after example.

Notes & Gotchas

  • Use the most complete, realistic sample you have - the schema can only be as rich as the example.
  • Remember every field becomes required; loosen the schema manually if a field is truly optional.
  • Check integer versus number inference when a field might later hold decimals.
  • Keep null out of the sample unless you want that field typed as string.

Frequently Asked Questions

Why are all fields marked required?

Strict mode in OpenAI Structured Outputs requires every property to be listed in required; the API rejects schemas that mark fields optional. The generator follows the spec rather than common practice.

Why does additionalProperties: false appear everywhere?

Strict mode requires additionalProperties: false on every object at every nesting level. The generator applies it to the root and to each nested object automatically.

How are array item types decided?

From the first element of the sample array. An empty array yields an unconstrained items schema, since there is nothing to infer from.

What happens to null values in my sample?

A null is inferred as a string type, because no type information can be recovered from null. Replace it with a real value in the sample for a better inference.