Controlling the Output Format
Telling the AI exactly how to shape its answer — as a table, JSON, bullet points, or a one-paragraph summary — gets you a result you can use immediately, instead of a wall of prose you have to reformat by hand.
Learn Controlling the Output Format in our free Prompt Engineering course — a beginner-friendly interactive lesson with worked examples, a practice exercise…
Part of the free Prompt Engineering course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
You almost always know where the answer is going next: a spreadsheet, a program, a slide, a quick scan. Say so. This lesson shows you the formats worth asking for and how to nail length, too.
What You'll Learn in This Lesson
1 Say where the answer is going
If you don’t name a format, the model defaults to paragraphs — and you waste a round re-asking. Same question, two prompts:
You get rambling prose you’d have to reformat to use anywhere.
Spreadsheet-ready, sorted, no fluff — usable the instant it arrives.
2 A catalog of formats to ask for
Format
Ask for it when…
📊 Table / CSV
You want spreadsheet-ready rows and columns.
🔧 JSON
A program will read the output — name the keys.
• Bullet list
You want a quick, scannable summary.
1. Numbered steps
Order matters (a recipe, a how-to).
📝 Markdown
You want headings and bold that render in docs.
¶ One paragraph
You need flowing prose, not a list.
For JSON, add “return ONLY valid JSON, nothing before or after” so a chatty intro doesn’t break your parser.
3 Control the length precisely
“Keep it short” is vague. Concrete limits work far better:
📋 Copy-paste output-format template
Common Mistakes (and the fix)
- Not naming a format. — You get prose; say “as a table” or “as JSON”.
- Asking for JSON without “only JSON”. — A friendly sentence sneaks in and breaks parsers.
- Saying “keep it short”. — Give a number: 3 bullets, under 100 words.
- Forgetting to name the columns/keys. — Specify them so the structure is predictable.
Frequently Asked Questions
⏱ Test Yourself — Timed Quiz
10 quick questions, 12 seconds each. Instant feedback — beat the clock!
🎉 Lesson Complete
- ✅ Name the format — table, JSON, bullets — so the answer is usable now
- ✅ For JSON, demand “only JSON, nothing else” and name the keys
- ✅ Control length with concrete limits, not “keep it short”
- ✅ Forbid preamble when you want just the answer
- ✅ Picture where the output lands and ask for that exact shape
Practice quiz
Why specify the OUTPUT FORMAT in your prompt?
- It is rude not to
- It makes the AI slower
- You get the answer in a shape you can use right away, with less re-prompting
- It has no effect
Answer: You get the answer in a shape you can use right away, with less re-prompting. Naming the format saves back-and-forth and gives you a usable, predictable result.
You want data you can paste into a spreadsheet. Ask for…
- A table or CSV with named columns
- A poem
- A long paragraph
- Just one word
Answer: A table or CSV with named columns. Tables or CSV map cleanly into spreadsheet rows and columns.
To get machine-readable output for a program, request…
- A story
- A bulleted list of feelings
- Random text
- Valid JSON with specific keys
Answer: Valid JSON with specific keys. JSON with defined keys is the standard machine-readable format.
Which prompt controls length best?
- 'write about dogs'
- 'summarize this in exactly 3 bullet points, under 15 words each'
- 'tell me stuff'
- 'go on'
Answer: 'summarize this in exactly 3 bullet points, under 15 words each'. Stating a precise count and word limit controls length reliably.
For a quick scannable answer, ask for…
- A bulleted or numbered list
- One giant paragraph
- JSON only
- No formatting
Answer: A bulleted or numbered list. Bullet and numbered lists are easy to scan.
If you need only the answer with no preamble, say…
- 'explain everything'
- 'be friendly'
- 'reply with only the answer, no introduction or sign-off'
- 'add lots of context'
Answer: 'reply with only the answer, no introduction or sign-off'. Explicitly forbidding preamble removes the chatty intro and outro.
Asking for JSON but the model adds a sentence before it. Best fix?
- Give up
- Say 'return ONLY valid JSON, nothing before or after'
- Ask for a poem
- Ignore it
Answer: Say 'return ONLY valid JSON, nothing before or after'. Emphasizing 'only JSON, nothing else' keeps the output clean and parseable.
To compare options side by side, request…
- A single number
- A haiku
- A wall of text
- A table with one row per option and columns for each criterion
Answer: A table with one row per option and columns for each criterion. A comparison table lines options up against the same criteria.
Which is a length constraint?
- 'use JSON'
- 'keep it under 100 words'
- 'use a table'
- 'be formal'
Answer: 'keep it under 100 words'. A word or sentence limit constrains length.
Markdown formatting is handy when you want…
- Raw bytes
- A binary file
- Headings, bold, and lists that render nicely in docs and chat
- No structure at all
Answer: Headings, bold, and lists that render nicely in docs and chat. Markdown gives readable headings, bold, and lists in most chat and doc tools.
Continue this course
- Previous: Chain-of-Thought Reasoning
- Next: Prompting AI to Write Code