JSON schema prompt builder
Getting an LLM to return clean, parseable JSON is mostly a prompting problem.
Ask loosely and you get markdown fences, chatty preambles, and stray keys that
break your parser. This builder takes your schema — or a sample object — and
writes an instruction block that pins down every field, restates its type,
marks what is required, and forbids anything that would trip up JSON.parse.
How it works
The tool accepts either a JSON Schema or a plain example object. From a schema
it reads properties, type, and required; from an example it infers field
names and types directly. It then assembles an instruction block listing each
field with its expected type and whether it is required, plus a set of
guardrails sized to your chosen strictness: return only JSON, no markdown fence,
no commentary, and — in strict mode — no keys beyond those in the schema. You
paste the block into your prompt and the model has an unambiguous contract.
Tips and notes
- Use strict mode for pipelines. When the output feeds code, the no-extra-keys, no-prose rules are what keep your parser happy.
- Combine with native JSON mode where the model supports it — the prompt and the feature reinforce each other.
- Spell out enums and formats in the schema (e.g.
"status": "active|paused") so the reminders carry that detail through. - Always parse defensively. Even a strict prompt can occasionally slip; wrap the parse in a try/catch and retry rather than trusting it blind.