Not every answer must be JSON or XML. Markdown formatting is the human-facing twin of structured output: headings, lists, tables, and fenced code that render cleanly in chat UIs, docs, and tickets. It complements JSON (for machines) and XML (for tagged sections).
In Module 13.2 you will refine presentation further via tone and output-format craft; here the focus is reliable Markdown as a prompt and response contract.
Learning Objectives
By the end of this lesson, students should be able to:
- Specify Markdown structure (H2s, bullets, tables, code fences) in prompts.
- Choose Markdown vs. JSON based on human vs. machine consumers.
- Prevent fence leakage and broken tables in model output.
- Use Markdown inside system prompts as a style guide.
- Combine Markdown answers with machine-readable footers when needed.
- Evaluate format compliance (heading presence, list length).
Markdown formatting (in prompting) means instructing the model to organize its reply using Markdown syntax—headings, emphasis, lists, links, tables, and fenced code blocks—so the result is scannable for humans and consistently renderable in Markdown-aware clients.
What to Specify
Structure
- Exact heading titles
- Bullet vs. numbered
- Section order
Constraints
- Max bullets / words
- No extra sections
- Language / tone
Code
- Fence language tags
- Complete snippets
- No stray fences
| Consumer | Prefer | Why |
|---|---|---|
| Chat / docs UI | Markdown | Readable, renderable |
| Backend service | JSON / tools | Typed parse |
| Mixed product | Both | MD body + JSON appendix |
Practical Format Spec
Headings & limits.
Markdown reply.
UI or docs.
Section presence.
Strengths
- Excellent human UX
- Native to chat products
- Easy partial compliance checks
Tradeoffs
- Weaker than schemas for data
- Tables can break under stress
- Fence confusion with code tasks
“Ask for Markdown and the model will always produce a perfect GFM table.” Complex tables are a frequent failure mode. Prefer short tables, or use JSON for tabular data and render Markdown yourself in the app.
Knowledge Check
- Short Answer: What is Markdown formatting in prompting? Answer: Instructing replies to use Markdown structure for scannable, renderable text.
- True/False: Markdown is usually best for typed database writes. Answer: False—prefer JSON/tools.
- Multiple Choice: Specifying exact heading titles helps: (a) compliance checks, (b) CUDA occupancy, (c) batch norm. Answer: (a).
- Short Answer: Name one Markdown failure mode. Answer: Broken tables or whole-reply code fences (among others).
- True/False: You can mix a Markdown body with a JSON appendix. Answer: True.
- Multiple Choice: Prefer Markdown when the consumer is: (a) a human reader/UI, (b) a strict schema validator only, (c) a kernel driver. Answer: (a).
- Short Answer: Why limit bullet count? Answer: Keeps answers concise and evaluable.
- Short Answer: Where can FORMAT rules live durably? Answer: In the system prompt (or a shared template).
- Multiple Choice: Rendering JSON as Markdown in the app is useful when: (a) tables are unreliable from the model, (b) JSON is illegal, (c) GPUs overheat. Answer: (a).
- True/False: Format checks belong in prompt evaluation. Answer: True.
Key Takeaways
- Markdown is the human contract; JSON is the machine contract.
- Specify sections, lengths, and fence rules explicitly.
- Validate structure; render hard tables in code when needed.
- Next: System Prompt—where durable format rules often live.
Hands-on: A/B a vague “use Markdown” vs. the exact section template above; score heading compliance.
Discussion: Should product UIs hide raw Markdown or show a rich preview?
Recap: Markdown formatting makes answers scannable when you specify the skeleton. Continue with System Prompt.