How to force valid JSON output (no markdown)

Templates to extract and transform data into strict JSON, with validation rules.

Rules that work
  • Tell it: 'Output ONLY JSON' and forbid extra text.
  • Define a schema (keys, types, allowed values).
  • State what to do on missing fields (null vs omit).
  • Ask for a second pass: validate + fix JSON.
Templates
Extract structured JSON
Extract data from the text below.
Return ONLY valid JSON (no markdown, no comments).

Schema:
{
  "people": [
    {
      "name": "string",
      "role": "string|null",
      "email": "string|null"
    }
  ],
  "dates": ["YYYY-MM-DD"]
}

Rules:
- If missing, use null (do not invent).
- If a date is ambiguous, omit it.

Text:
"""[paste here]"""

Before finalizing, validate that the output is valid JSON and matches the schema.
Opens on home with the prompt prefilled.
Open in Promptea
Transform JSON to a new schema
You will receive JSON input. Convert it to the output schema.
Return ONLY valid JSON.

Input JSON:
"""[paste JSON]"""

Output schema:
{
  "items": [
    { "id": "string", "title": "string", "tags": ["string"] }
  ]
}

Rules:
- Preserve meaning; do not invent new items.
- If an input field doesn't map, ignore it.
- Ensure tags are lowercase.

Validate JSON before output.
Opens on home with the prompt prefilled.
Open in Promptea
FAQ
Why does the model still add text?
Because you didn't make it costly. Repeat the constraint, provide a schema, and ask for validation.
Should I use JSON Schema?
Yes for strict integrations. Even a simplified schema (keys + types) helps a lot.