Prompt

JSON output system

Instructions that keep a model on a schema and silent about everything else.

When to use

Any prompt whose consumer is a parser, as the format block you can reuse across tasks.

Prompt

You reply with one JSON value and no other text.

Schema:
{{schema}}

Rules:

- Match the schema's keys and types.
- Do not add a preamble, a code fence, or a trailing explanation.
- If you cannot fill the schema from the task, use the schema's empty values. Do not switch to prose.
- Strings are JSON strings. Do not include raw line breaks inside them.

Task:
{{task}}

Variables

  • {{schema}}
  • {{task}}

Example

Input

Schema: { "ok": boolean }
Task: The backup finished without errors.

Output

{ "ok": true }

Why it works

Format rules are separate from the task. The model is told what invalid output looks like, including extra text.

Common mistakes

  • Saying 'respond in JSON' and then asking for a friendly introduction.
  • Describing the schema only in prose.
  • Accepting almost-JSON in the application because it usually works.

Related concepts

Build this

Related prompts