Output Shaping: Asking for Tables, Lists, JSON, Diff
Control the format of Copilot's output to save follow-up turns.
What You Will Learn
- Request specific output formats: tables, lists, JSON, diff.
- Use format to enable downstream automation.
- Avoid common format pitfalls.
- Combine format with role and specificity.
- Validate structured output programmatically.
Why This Matters
Asking 'list the bugs' produces prose; asking 'output as a JSON array of {severity, issue, fix}' produces parseable data. Output shaping saves a follow-up turn and unlocks automation (feeding Copilot's output to a script).
Concept Explained
Output shaping means specifying the response format in the prompt. Common formats: bullet list, numbered list, table, JSON, diff, markdown code block. The format shapes what the model produces, not just how it looks.
How It Works
Format instructions bias the model toward structured output. Asking for JSON activates JSON-producing patterns; asking for a table activates table-markdown patterns. Combine with a schema for maximum control: 'output as JSON matching this TypeScript type: {severity: 'high'|'med'|'low', issue: string, fix: string}'.
Step-by-Step Tutorial
1. Pick a format
Match format to use: bullet for reading, JSON for automation, table for comparison, diff for edits.2. Specify in prompt
End your prompt with: 'Output as [format]' or 'Format your response as [format]'.3. Add schema for JSON
For JSON, specify the shape: '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 wanted to feed Copilot's bug review into their issue tracker. They asked: 'Review this function. Output as JSON array of {severity, title, description, suggested_fix}. No prose.' Copilot produced clean JSON. They wrote a 10-line script to file issues automatically. Saved ~30 minutes per review.
Example Prompts / Commands / Code
# Bullet list:
List the top 3 performance issues. Output as a bullet list, no prose.
# Table:
Compare these 3 libraries. Output as a markdown table with columns: library, stars, last_release, license.
# JSON with schema:
Review this function for security issues. Output as JSON matching this TypeScript type:
type Issue = { severity: 'high'|'med'|'low'; issue: string; fix: string };
Return Issue[].
# Diff:
Refactor this function. Output as a unified diff, no prose around it.
# Code block only:
Implement the function. Output as a single TypeScript code block, no explanation.
Common Mistakes
- Asking for JSON without a schema — produces inconsistent shapes.
- Mixing prose with structured output — defeats the purpose.
- Forgetting to validate JSON — silent parse failures downstream.
- Using tables for >5 columns — hard to read.
Best Practices
- Match format to use: JSON for automation, table for comparison, diff for edits.
- For JSON, always specify a schema.
- End with 'no prose' or 'no explanation' if you want clean output.
- Validate structured output before consuming.
Troubleshooting
| Problem | How to Fix |
|---|---|
| JSON is malformed | Add 'must be valid JSON, no trailing commas, no comments'. Or try a different model. |
| Prose creeps in | End prompt with 'Output ONLY the [format], no surrounding text'. |
| Table is unreadable | Switch to a list of objects, or simplify columns. |
Practical Exercise
Your Turn
Ask Copilot to review a function for bugs. First, ask for prose. Then ask for a JSON array with schema. Compare usefulness for downstream automation.
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 structured output.
- Validate structured output before consuming.
Frequently Asked Questions
Can I get YAML or XML?
Does format affect credit cost?
Can I get multiple formats in one response?
Further Reading
Official References
Related lessons: BE-17, BE-19, IN-04
SEO Metadata
SEO title: Output Shaping: Asking for Tables, Lists, JSON, Diff
Meta description: Control the format of Copilot's output to save follow-up turns.
Primary keyword: output shaping
Secondary keywords: output shaping: asking for tables, lists, json, diff
Search intent: Informational
URL slug: /copilot-output-shaping-tables-json-diff
Categories: AI Tools, GitHub Copilot
Tags: GitHub Copilot, Beginner, Prompting, Output Format, IMCSEIAN, Tutorial, IMCSEIAN
Featured image concept: IMCSEIAN lesson card for Output Shaping: Asking for Tables, Lists, JSON, Diff
Comments
Comments
Post a Comment