HTML Element to Markdown Mapping Prompt
Without rules, conversions vary from one run to the next. This prompt sets down a plain mapping table for standard elements, including how to treat nesting and whitespace. Use it as the standard-conversion step after any special-case checks.
Convert the HTML below to Markdown using exactly these mapping rules. Block elements: - h1 to h6: one to six # characters, with a blank line before and after - p: plain paragraph, separated by blank lines - ul and ol: "-" bullets and "1." numbering, indented two spaces per nested level - blockquote: lines starting with ">" - hr: --- - pre: fenced code block Inline elements: - strong and b: **bold** - em and i: *italic* - a: [text](url). If the link text is empty, use the URL as text. - code: backticks - br: line break - img: . If alt is missing, use an empty alt and note it. General rules: - Remove scripts, styles, inline event attributes and empty elements. - Collapse repeated blank lines into one. - Keep relative URLs as they are. - Do not add text that is not in the HTML. HTML: [paste HTML]
Adapted from a prompt in awesome-chatgpt-prompts (CC0), rewritten by Retext.
How to use this prompt
- 1
Copy the prompt
Use the copy button, or type its Retext trigger in any app to paste it.
- 2
Open your AI assistant
Start a new chat in ChatGPT, Claude, Gemini or the assistant you use.
- 3
Fill in the details
Replace any [bracketed] parts with your own details.
- 4
Check and refine
Read the answer, then reply with one change at a time.
Tips for better results
- •Decide on bullets and numbering style before you start. Mixed styles across many pages are annoying to clean up later.
- •Ask for the missing-alt note in a final list. It doubles as an accessibility check on the source page.
- •Paste a short page first. If the output follows your rules, then run the long ones.
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.
Variations
Hugo or Jekyll output
Add this line: Add front matter with title, date and source URL at the top in YAML.
Plain text mode
Add this line: Strip all Markdown formatting and keep only paragraph breaks and list dashes.
Save it as a Retext snippet
Retext is a free text expander for Mac. Save this prompt once, then type ;html-to-md in any app (ChatGPT, Claude, your editor, a browser tab) and the full prompt is pasted in.
- Click Add to Retext. The prompt installs as a snippet with the trigger ;html-to-md.
- Change the trigger in Retext if you prefer a different one.
- Type the trigger wherever you want the prompt, then fill in the brackets.
Frequently asked questions
What does the HTML Element to Markdown Mapping prompt do?
Without rules, conversions vary from one run to the next. It's written for developers.
Which AI tools does it work with?
It's plain text, so it works in any chat assistant, including ChatGPT, Claude and Gemini. Paste it as the first message of a new chat.
What do I need to fill in?
Replace [text], [alt], [paste HTML] with your own details. Leave the rest as it is unless you want to change how the AI answers.
Can I save this prompt as a snippet?
Yes. Click Add to Retext and it installs as a snippet with the trigger ;html-to-md. Type that in any Mac app to paste the full prompt.
Related Templates
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.