AI Structured Output / JSON Prompt Builder
Check a JSON Schema (2020-12) in your browser, validate a sample with path-specific errors, and get a prompt that keeps required and nullable keys separate.
Task and schema
The schema is checked in your browser (JSON Schema draft 2020-12 subset). Remote references are never fetched and no AI is called.
Draft 2020-12. Local $ref only (#/$defs/…).
Paste a model response (or your own sample) to check it against the schema.
Generation is blocked until the schema parses and checks cleanly.
Prompt text alone cannot force valid JSON. Validate every response, and use a provider's structured-output feature where you need enforcement — after checking which schema keywords it supports.
How to use this calculator
- Describe the task and paste a JSON Schema (draft 2020-12). Local $ref references into $defs are supported; remote ones are refused and never fetched.
- Say whether the prompt alone constrains the output or a provider's structured-output feature also receives the schema. Optionally paste a sample response to validate.
- Read the flow status, the field table and any errors, then copy or download the generated prompt.
How it works
The schema is parsed and checked locally: valid JSON, the 2020-12 dialect, known types, valid patterns and local references only. Invalid JSON, a remote, unresolved or cyclic $ref, or an unknown type blocks generation and is listed with its schema path.
Type, required and nullability are separate (JSON Schema 2020-12). “required” only means the key must be present; null is allowed only when the type includes "null". The prompt states both for every field, so it never tells the model to use null where the schema forbids it.
The sample validator checks type, enum, const, string length and pattern, number limits, array items and uniqueness, required keys, additionalProperties and anyOf / oneOf / allOf / not, and reports each problem with its path (for example /name). Other keywords are listed as a limitation rather than silently passed.
An example of the shape is generated only when it can be built from supported keywords and passes the schema itself. Prompt text alone cannot enforce JSON; even provider features support different subsets of JSON Schema.
Worked example
Contact extraction with a nullable phone. Schema: name string (minLength 1), email string, phone ["string","null"], company string; required name, email, phone; additionalProperties false. The prompt says name is required and never null, phone is required and null is allowed, company is optional and never null, and no other key may be added. The sample {"name": null, "email": "a@b", "phone": null, "x": 1} fails at /name (null is not allowed — the type is string) and /x (not allowed).
Frequently asked questions
Does this use AI or send my prompt anywhere?
No. It runs entirely in your browser using rule-based checks — your prompt is never uploaded or sent to any AI model. Still, avoid pasting passwords, API keys or private data into any tool.
Can required fields be null?
Only if their type includes null. Required means the key must be present; nullability comes from the type. A required string rejects null; a required ["string", "null"] accepts it.
Why is my sample invalid?
The error table gives the path in your sample, the keyword that failed and the reason — for example a null where the type is string, a missing required key, or an extra key when additionalProperties is false.
Does the prompt enforce JSON?
No. A prompt only asks. Validate every response, and use a provider's structured-output feature where you need enforcement, after checking which schema keywords it supports.
Related tools
- AI Data Analysis Prompt Builder
- Claude Code Prompt Builder
- AI Citation Requirements Prompt Builder
- JSON Formatter & Minifier
- AI Agent Spec Builder
- AI Token & Cost Estimator
Explore more in AI Tools.
Cite this tool
Zerdly. (2026). AI Structured Output / JSON Prompt Builder. Retrieved from https://www.zerdly.com/tools/ai-structured-output-prompt-builder/
Tip: Enter any known values to calculate the remaining results.
Designed to run locally in your browser. Tool inputs are not intentionally stored by Zerdly unless stated otherwise.



