Markdown Formatting in Prompts
Headers, bold, code blocks — how to specify rich formatting.
Markdown in AI Output
Markdown is a lightweight text formatting syntax that AI models understand natively. When you ask for markdown-formatted output, the model produces text that renders as rich formatting in compatible environments.
Knowing exactly how to request each markdown element gives you precise control over the structure of every AI-generated document.
Requesting Headers
Markdown headers use hash symbols: # for H1, ## for H2, ### for H3.
Request them explicitly: 'Structure with H2 section headers', 'Use ## for main sections and ### for subsections', or 'Include a single # H1 title at the top.'
Headers create navigable structure in Notion, GitHub, Obsidian, and most documentation tools.
import anthropic
client = anthropic.Anthropic(api_key='sk-ant-your-key-here')
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=400,
messages=[{
'role': 'user',
'content': (
'Write a technical guide outline for "Getting Started with FastAPI". '
'Structure: one # H1 title at the top, then 4 ## H2 section headers, '
'each with 2 ### H3 subsection headers beneath it. '
'Add one sentence of placeholder content under each H3.'
)
}]
)
print(response.content[0].text)All lessons in this course
- Requesting Lists and Bullet Points
- Asking for Tables and Structured Data
- Markdown Formatting in Prompts
- Plain Text vs Formatted Output