Markdown for AI Prompts
Markdown gives an AI prompt a structure a model can follow, so the model can tell your instructions from your data. Headings mark a new section, lists separate items, and code fences stop code from being reformatted.
This page covers the Markdown syntax you need in prompts, then how each part helps the model. The Markdown cheat sheet adds the rest of the syntax, such as task lists, line breaks and escaping.
The syntax you need for prompts
Headings split a document or prompt into sections:
# Heading 1
## Heading 2
### Heading 3
Emphasis:
**bold** *italic* ~~strikethrough~~ `inline code`
Lists, unordered and ordered (indent to nest):
- item
- item
- nested item
1. first
2. second
Links and images:
[link text](https://example.com)

Code blocks. Fence them with three backticks, and add a language name for highlighting:
```python
print("hello")
```
Blockquotes:
> quoted text
Tables. Pipes and dashes, with the header row above a divider:
| Column A | Column B |
| --- | --- |
| value | value |
Horizontal rule:
---
Why Markdown helps in AI prompts
- Headings. If you paste a document plus instructions, put them under clear
##headings, such as "## Document" and "## Task". The structure helps the model keep your instruction apart from your data. It also makes it less likely that the model treats part of the source text as a command. - Numbered lists. If you ask for several things, number them, so each request stands on its own line instead of being buried in one sentence.
- Code fences. Wrap code, JSON or config in triple backticks, and the model is less likely to reformat it or read stray characters as instructions.
- Tables. For facts that pair a label with a value, use a small Markdown table. A model reads it more easily than the same facts written as a paragraph.
Markdown costs tokens
Markdown is light, but structure isn't free. Every #, | and - is a character, and characters become tokens. For a short prompt the cost is tiny. For a large pasted document, heavy formatting adds up. If you are near a model's limit, measure the document with the token counter instead of guessing.
Getting clean Markdown in the first place
When your source is a PDF, Word file or web page, convert the document to Markdown first. You get the headings, lists and tables above, already laid out for a model to read. To write and preview Markdown by hand, the Markdown editor shows the rendered result as you type.
Before your next long prompt, put the source under a "## Document" heading and the request under "## Task", with each request as a numbered item. For any syntax not covered here, open the Markdown cheat sheet.
Try it on your own file
Convert a document and watch the token counter. It's free, needs no account and uploads nothing.