Output Shaping: Tables, Lists, JSON, Markdown
Control the format of Gemini's output to save follow-up turns.
What You Will Learn
- Request specific output formats.
- Use format to enable downstream automation.
- Avoid common format pitfalls.
- Combine format with role and specificity.
- Validate structured output.
Why This Matters
Asking list the bugs produces prose. Asking output as JSON array of {severity, issue, fix} produces parseable data. Output shaping saves a follow-up turn and unlocks automation.
Concept Explained
Output shaping means specifying the response format in the prompt. Common formats: bullet list, numbered list, table, JSON, Markdown code block, diff.
How It Works
Format instructions bias Gemini toward structured output. Asking for JSON activates JSON-producing patterns. Combine with a schema for maximum control.
Step-by-Step Tutorial
1. Pick a format
Bullet for reading, JSON for automation, table for comparison, diff for edits.2. Specify in prompt
End with: Output as [format].3. Add schema for JSON
Output as JSON matching: {severity: string, issue: string, fix: string}[].4. Combine with role
Act as a security reviewer. Output as a table with columns: severity, issue, fix.5. Validate
For JSON, run through a parser. For tables, check column count.Real-World Example
A team fed Gemini's bug review into their issue tracker. Asked: Output as JSON array of {severity, title, description, suggested_fix}. Claude produced clean JSON. They wrote a 10-line script to file issues automatically.
Example Prompts / Commands / Code
# Bullet list:
List the top 3 performance issues. Output as a bullet list.
# Table:
Compare these 3 libraries. Output as a markdown table.
# JSON with schema:
Review this function. Output as JSON matching:
type Issue = { severity: 'high'|'med'|'low'; issue: string; fix: string };
# Diff:
Refactor this function. Output as a unified diff.
# Code block only:
Implement the function. Output as a single TypeScript code block.
Common Mistakes
- Asking for JSON without a schema.
- Mixing prose with structured output.
- Forgetting to validate JSON.
- Using tables for more than 5 columns.
Best Practices
- Match format to use: JSON for automation, table for comparison.
- For JSON, always specify a schema.
- End with no prose for clean output.
- Validate structured output.
Troubleshooting
| Problem | How to Fix |
|---|---|
| JSON is malformed | Add must be valid JSON. Try Pro model. |
| Prose creeps in | End with Output ONLY the JSON, no surrounding text. |
Practical Exercise
Your Turn
Ask Gemini to review a function for bugs. First as prose. Then as JSON with schema. Compare.
Key Takeaways
- Format instructions shape output structure.
- Common formats: bullet, table, JSON, diff, code block.
- Always specify a schema for JSON.
- End with no prose for clean output.
- Validate structured output.
Frequently Asked Questions
Can I get YAML or XML?
Does format affect token cost?
Further Reading
Official References
SEO Metadata
SEO title: Output Shaping: Tables, Lists, JSON, Markdown
Meta description: Control the format of Gemini's output to save follow-up turns.
Primary keyword: gemini output format
Secondary keywords: gemini json output, gemini markdown, gemini table, gemini structured output
Search intent: Informational
URL slug: /gemini-output-shaping-tables-json-markdown
Categories: AI Tools, Google Gemini
Tags: Gemini, Beginner, Prompting, Output Format, JSON, Markdown, IMCSEIAN, Tutorial, IMCSEIAN
Featured image concept: IMCSEIAN Gemini lesson card for Output Shaping: Tables, Lists, JSON, Markdown
Comments
Comments
Post a Comment