Lesson 707 of 1570
Output Format Control: JSON, Tables, Schemas, and Structure
Tell AI the shape of the answer (table, bullets, JSON) and you stop wasting time reformatting.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1The big idea
- 2Prompting AI: lock the output format
- 3The big idea
- 4AI and Constraint Prompts: Less Is More
Concept cluster
Terms to connect while reading
Section 1
The big idea
When you ask AI a question, the answer comes back however the AI feels like writing it. If you want a table, a bulleted list, or a numbered plan, you have to ask for it directly. Format requests save you tons of editing time.
Some examples
- 'Give me 5 study tips as a numbered list, max 10 words each.'
- 'Reply as a 3-column table: Pro / Con / My take.'
- 'Write this as a script with SPEAKER: lines, no stage directions.'
- 'Output JSON with keys title, summary, difficulty.'
Try it!
Ask AI for 'three weekend project ideas' once with no format request, then again as 'a 3-row table with columns: Idea, Materials, Hours.' Notice how much faster the second one is to scan.
Key terms in this lesson
Section 2
Prompting AI: lock the output format
Section 3
The big idea
AI loves to ramble. If you say 'give me exactly 5 bullet points, each under 10 words,' you get exactly that. Locking the format makes AI usable inside other tools.
Some examples
- 'Reply only as JSON with these keys: name, age, score'
- 'Exactly 3 bullets, no intro, no outro'
- 'Markdown table only, no commentary'
- 'One sentence answer, under 20 words'
Try it!
Ask AI a question with no format rules. Then ask again with strict format rules. Notice how the strict version is way easier to use.
Section 4
AI and Constraint Prompts: Less Is More
Section 5
The big idea
AI loves to ramble. The fix: hard constraints. 'Exactly 100 words.' 'No bullet points.' 'Don't use the word amazing.' Constraints make output usable.
Some examples
- Prompt: 'Reply in exactly 50 words. Do not use the word innovative.'
- Prompt: 'Output ONLY a JSON array. No prose around it.'
- Prompt: 'Use 8th-grade vocabulary or simpler.'
- Prompt: 'Maximum 3 bullets. Each bullet under 12 words.'
Try it!
Ask AI for a class president speech with 4 hard constraints. Then remove them and compare results.
Section 6
Asking ChatGPT for JSON, a Table, or a Bullet List — Be Boringly Specific
Section 7
The big idea
'Give me some ideas' returns a wall of text. 'Give me 5 ideas as a numbered list, each one max 10 words' returns something you can use immediately. Format requests are free and they always work. Bonus: most models now have a JSON mode for guaranteed-parseable output if you're coding.
Some examples
- 'Return as a markdown table with columns Name | Pros | Cons.'
- 'Reply as JSON: {idea: string, score: 1-10, reason: string}.'
- 'Bullet list, max 5 bullets, max 10 words each. Nothing else.'
- 'CSV format. First row is the header. No prose before or after.'
Try it!
Pick three prompts you'd normally just ask in plain English. Add a one-line format spec to each. Compare results.
Section 8
Showing AI Examples Beats Explaining the Format
Section 9
The big idea
Few-shot prompting means giving the model examples of input-output pairs before your real input. Models are great at pattern-matching: show them the format twice and they'll match it. Trying to *describe* the format in words is slower and less reliable.
Some examples
- You want emoji-tagged TODOs. Give 3 examples ('🔥 fix the login bug') instead of describing the rule.
- You want SQL in a specific dialect. Show 2 example queries; the AI matches your style.
- You want haikus about programming. Two examples lock in the 5-7-5 better than the rule alone.
- You want bug reports in a strict template. Paste 2 filled-in templates as examples.
Try it!
Pick a format you keep tweaking. Write 3 perfect examples once. Save them as a snippet. Paste them above every prompt that needs that format.
Section 10
Putting the Constraints Before the Request, Not After
Section 11
The big idea
Models pay more attention to what comes before the main task. Put format rules and constraints at the top of the prompt — at the bottom they get half-followed.
Some examples
- 'Reply in exactly 3 bullets, no preamble:' at the top of the prompt actually gets you 3 bullets.
- 'Use only the data I paste' before the data keeps Claude from inventing fields.
- 'Write in past tense' at the top prevents the AI from drifting to present mid-paragraph.
- Setting 'no markdown' upfront stops ChatGPT from sneaking in headers.
Try it!
Find a prompt where the AI ignored your format request. Move the format rule to the top. Try again.
Section 12
Asking AI for JSON That Actually Parses (Schema in the Prompt)
Section 13
The big idea
If you ask 'give me JSON' you get JSON with extra prose. If you paste the exact schema you want and say 'fill this in, no other text' you get clean parseable JSON. Schema in the prompt is the simplest structured-output trick.
Some examples
- Pasting `{"title": string, "tags": string[]}` and 'fill this' gets back valid JSON.
- Claude given a Zod-style schema returns matching nested structures.
- ChatGPT with 'no markdown, no prose, JSON only' returns code you can JSON.parse directly.
- Cursor reading a TypeScript interface produces test fixtures matching it.
Try it!
Write a prompt that asks for a 3-field JSON object. Try without a shown schema, then with. Compare parse rates.
Section 14
Pinning the Output Format Down to a JSON Schema
Section 15
The big idea
format constraints save more time than they cost
Some examples
- Asking for an array of objects with title and date
- Including a sample row
- Telling it not to wrap in markdown
Try it!
Open your favorite AI tool and try one of the examples above. Pick the one that matches what you are actually working on this week. Spend 10 minutes, no more. Notice what worked and what did not — that's the real lesson.
Section 16
Structured output: get clean JSON every time
Section 17
The big idea
Most APIs let you say 'output JSON matching this schema' and the model will obey reliably.
Some examples
- Define the schema with field names and types.
- Use the SDK's structured-output feature, not just 'please give me JSON.'
- Validate the result with a schema library (Zod, Pydantic) anyway.
Try it!
Take an AI feature in your project. Switch it to structured output with a schema.
Understanding "Structured output: get clean JSON every time" in practice: Prompting is a skill: the more specific and structured your input, the more useful the output. Stop parsing weird AI text — use JSON mode or structured outputs and get reliable shapes — and knowing how to apply this gives you a concrete advantage.
- Use role, context, task, and format in every prompt
- Iterate: treat first outputs as drafts, not finals
- Use few-shot examples for complex formatting tasks
- Test prompts at different temperatures for creative vs. factual tasks
- 1Rewrite one of your best prompts using role + context + task + format
- 2Ask an AI to critique your prompt and suggest improvements
- 3Compare outputs from two models using the same prompt
Section 18
AI and Format Control: Get JSON, Tables, and Outlines on Demand
Section 19
The big idea
Most teens accept whatever paragraph dump AI returns. Asking for a table, a JSON object, or a numbered list with character limits makes the answer instantly usable in your real workflow.
Some examples
- Ask Claude for a table with columns and rows — and a max of 50 chars per cell.
- Ask ChatGPT for valid JSON with three keys — and nothing else.
- Ask Gemini for an outline with exactly 3 levels and 7 bullets per level.
- Ask Perplexity for citations in MLA 9 format directly inline.
Try it!
Take your next prompt. Add 'output format: [table/json/outline] only.' Watch the cleanup time go to zero.
Section 20
Controlling Output Format: JSON, Tables, and More
Section 21
The big idea
Asking for unstructured prose is fine for chat, but if you want to use AI in a workflow — feeding output to other tools, building tables, processing data — you need to control format precisely. Just asking for JSON, a table, or a specific schema unlocks completely new uses.
Some examples
- 'Reply only in JSON with keys: summary, tags, action_items.'
- 'Output as a markdown table with columns Name, Role, Year.'
- Show one example of the format you want.
- Most major models have a 'JSON mode' or 'structured output' feature in their API.
Try it!
Take any AI task you do regularly. Add 'output as a markdown table with columns X, Y, Z' and notice how much more useful it gets.
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “Output Format Control: JSON, Tables, Schemas, and Structure”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Explorers · 40 min
Format Your Answers: Lists, Tables, Length, and Layout, Part 2
You can ask AI for short, medium, or long answers — your choice.
Creators · 40 min
Output Format Engineering: Schemas, Length Control, and Reliability, Part 1
If you're parsing model output in code, format reliability matters as much as content quality. Here's how to architect prompts and validators that produce parseable output even from imperfect models.
Builders · 40 min
Few-Shot Prompting: Teaching AI by Showing Examples
Tell AI 'don't do it like this' with a real bad example, and it learns the line you're drawing.
