Force JSON Output from AI
Stop getting 'Sure, here is the JSON…' — the output-contract pattern that forces models to return only parseable JSON: schema, example, and a strict rule block.
When the destination is a spreadsheet, CSV is the contract: one header row, one data row, quoting rules, and an honest answer about nested data.
CSV output earns its place when the consumer is a spreadsheet or a bulk importer — and it punishes vagueness harder than JSON, because there's no syntax to lean on: a stray comma silently shifts every column after it. The CSV contract pins the header row to the schema names, demands exact quoting for cells with commas or quotes, and handles CSV's structural limit honestly: arrays get joined with '; ', and genuinely nested data triggers a recommendation to use JSON instead. This resource loads a lead-qualification contract in CSV mode, flat fields chosen deliberately.
Generate in CSV mode
The builder warns when your schema has array/object fields — CSV is flat, and the contract says so honestly.
Check the quoting rule
Cells with commas must be quoted, quotes doubled — the rule that prevents silent column shifts.
Keep it to one data row per call
One row per response keeps validation trivial; batch by calling, not by asking for many rows.
It joins multiple values inside one cell with "; " — the VALIDATION RULES flag that the schema contains array fields and specify that separator, so pain_points lands as "item-one; item-two" in a single column. For deeply nested data it tells you to "prefer JSON" instead. The json-output-prompt-builder generates this contract; you run it, then load the CSV into your spreadsheet.
The quoting rule. OUTPUT RULES require "exactly one header row and one data row; quote cells containing commas," which closes CSV's silent column-shift hole where an unquoted comma pushes every later column over. The header row is pinned to the schema field names so column mapping is deterministic. You still validate the row parses — the builder writes the contract, it doesn't run the CSV.
When the data is deeply nested — the contract itself says so. The VALIDATION RULES join flat arrays with "; " but add "For deeply nested data, prefer JSON," and notFor confirms code consumers are better served by JSON's syntax guarantees than CSV's conventions. CSV earns its place only when the destination is a spreadsheet or bulk importer and the shape is flat.
Stop getting 'Sure, here is the JSON…' — the output-contract pattern that forces models to return only parseable JSON: schema, example, and a strict rule block.
Native JSON modes guarantee syntax, not your schema. The prompt contract that covers field names, types, and null discipline — whether or not the API has JSON mode.
Automation platforms fail silently on malformed model output. The strict contract that keeps AI steps feeding clean JSON into the rest of the flow.
Free text in, named fields out. The extraction prompt pattern that turns any unstructured text into consistent, parseable records.
The JSON won't parse and you can't see why. Deterministic cause-sniffing — trailing commas, single quotes, unclosed brackets — and the repair prompt that fixes it.
'Make it good', 'be detailed', 'keep it interesting' — vague prompts get vague output. The fix is mechanical: replace every fuzzy word with a checkable instruction.
Build prompts that return structured data — JSON first, with YAML, XML, and CSV modes — parseable every time.