Markdown Toolkit
Edit Markdown with live HTML preview or convert HTML snippets back to Markdown syntax.
Back to all tools on ToolForge
Output
About Markdown Toolkit
This Markdown toolkit provides a live preview editor for writing Markdown with instant HTML rendering, plus an HTML-to-Markdown converter for reverse transformation. It supports CommonMark and GitHub Flavored Markdown syntax for comprehensive documentation writing.
What is Markdown?
Markdown is a lightweight markup language created by John Gruber in 2004. It uses plain text formatting symbols that convert to HTML, enabling writers to focus on content rather than visual styling. Markdown has become the standard for:
- Software Documentation: GitHub READMEs, API docs, changelogs
- Static Sites: Jekyll, Hugo, Gatsby, Next.js blogs
- Forums & Chat: Reddit, Discord, Slack, Stack Overflow
- Note-taking: Obsidian, Notion, Bear, iA Writer
- Content Management: Ghost, Netlify CMS, Contentful
Markdown Syntax Reference
| Element | Markdown Syntax | Example Output |
|---|---|---|
| Heading 1 | # Title |
<h1>Title</h1> |
| Heading 2 | ## Title |
<h2>Title</h2> |
| Bold | **text** or __text__ |
text |
| Italic | *text* or _text_ |
text |
| Strikethrough | ~~text~~ |
|
| Link | [text](url) |
<a href="url">text</a> |
| Image |  |
<img src="src" alt="alt"> |
| Inline Code | `code` |
code |
| Code Block | ```lang\n...\n``` |
<pre><code>...</code></pre> |
| Blockquote | > quote |
<blockquote>quote</blockquote> |
| Unordered List | - item or * item |
<ul><li>item</li></ul> |
| Ordered List | 1. item |
<ol><li>item</li></ol> |
| Task List | - [ ] task |
☐ task |
| Horizontal Rule | --- or *** |
<hr> |
Markdown Table Syntax
Tables are part of GitHub Flavored Markdown (GFM):
Markdown Table: | Name | Age | City | |------------|-----|-------------| | Alice | 25 | New York | | Bob | 30 | San Francisco| | Charlie | 35 | Seattle | Renders as: ┌───────────┬─────┬───────────────┐ │ Name │ Age │ City │ ├───────────┼─────┼───────────────┤ │ Alice │ 25 │ New York │ │ Bob │ 30 │ San Francisco │ │ Charlie │ 35 │ Seattle │ └───────────┴─────┴───────────────┘ Alignment with colons: | Left | Center | Right | |:----------|:------:|----------:| | aligned | text | here | :--- = left align (default) :--: = center align ---: = right align
HTML to Markdown Conversion Reference
| HTML Element | Markdown Equivalent |
|---|---|
<h1>Title</h1> |
# Title |
<h2>Title</h2> |
## Title |
<strong>text</strong> |
**text** |
<em>text</em> |
*text* |
<a href="url">text</a> |
[text](url) |
<img src="url" alt="alt"> |
 |
<ul><li>item</li></ul> |
- item |
<code>code</code> |
`code` |
<blockquote>quote</blockquote> |
> quote |
<br> |
New line (double space at end) |
Markdown Conversion Algorithm
JavaScript HTML to Markdown Conversion:
function htmlToMarkdown(html) {
return html
// Headings
.replace(/(.*?)<\/h1>/gi, "# $1\n")
.replace(/(.*?)<\/h2>/gi, "## $1\n")
.replace(/(.*?)<\/h3>/gi, "### $1\n")
// Text formatting
.replace(/(.*?)<\/strong>/gi, "**$1**")
.replace(/(.*?)<\/b>/gi, "**$1**")
.replace(/(.*?)<\/em>/gi, "*$1*")
.replace(/(.*?)<\/i>/gi, "*$1*")
// Links and images
.replace(/(.*?)<\/a>/gi, "[$2]($1)")
.replace(/
/gi, "")
.replace(/<\/ul>/gi, "")
.replace(/(.*?)<\/li>/gi, "- $1\n")
// Other elements
.replace(/
/gi, "\n")
.replace(/(.*?)<\/p>/gi, "$1\n\n")
.replace(/(.*?)<\/code>/gi, "`$1`")
.replace(/(.*?)<\/blockquote>/gi, "> $1")
// Remove remaining tags
.replace(/<[^>]+>/g, "")
// Clean up whitespace
.replace(/\n{3,}/g, "\n\n");
}
// Usage:
const html = "Hello
This is bold text.
";
const md = htmlToMarkdown(html);
console.log(md);
// # Hello
//
// This is **bold** text.
Common Markdown Use Cases
- README Files: Document GitHub repositories with installation, usage, and API docs
- Technical Documentation: Write API references, tutorials, and guides
- Blog Posts: Create content for static site generators (Jekyll, Hugo, Gatsby)
- Forum Posts: Format questions and answers on Stack Overflow, Reddit, Discord
- Email Templates: Write formatted emails in apps that support Markdown
- Meeting Notes: Structure notes with headings, lists, and task items
- Content Migration: Convert HTML content to Markdown for modern CMS platforms
Markdown Flavors Comparison
| Flavor | Extensions | Used By |
|---|---|---|
| CommonMark | Standard base syntax | Standard spec |
| GitHub Flavored (GFM) | Tables, task lists, strikethrough, autolinks | GitHub, GitLab |
| Markdown Extra | Tables, footnotes, definition lists, attributes | Drupal, Stack Overflow |
| MultiMarkdown | Footnotes, tables, metadata, cross-references | Academic writing |
| RMarkdown | Code chunks, data visualization, dynamic docs | RStudio, data science |
Markdown Best Practices
- Use headings hierarchically: Start with # H1, then ## H2, ### H3—don't skip levels
- Keep line length reasonable: Break lines at 80-120 characters for readability in raw form
- Use reference-style links for long documents: Define links at bottom [link][ref]
- Escape special characters: Use backslash (\) to escape *, _, #, etc. when needed
- Include alt text for images: Describe image content for accessibility
- Use code blocks with language: ```javascript enables syntax highlighting
How to Use Markdown Toolkit
- Select mode: Choose "Markdown Preview" or "HTML to Markdown".
- Enter content: Write Markdown or paste HTML code.
- Click Run: Preview renders HTML or converts to Markdown.
- Copy result: Click "Copy Result" to use the output.
Tips
- In Preview mode, output is rendered HTML; copy gives plain text
- In HTML-to-Markdown mode, output shows Markdown in a code block
- Use the placeholder text as a syntax reference
- Complex HTML may not convert perfectly—review the output
- Tables and task lists require GitHub Flavored Markdown support
Frequently Asked Questions
- What is Markdown and why use it?
- Markdown is a lightweight markup language created by John Gruber in 2004. It uses plain text formatting symbols that convert to HTML, allowing writers to focus on content rather than styling. Markdown is widely used for documentation (GitHub READMEs), blogs (Static Site Generators), forums (Reddit, Discord), and note-taking apps (Obsidian, Notion).
- What Markdown syntax is supported?
- This tool supports CommonMark/GitHub Flavored Markdown: headings (# H1), bold (**text**), italic (*text*), links [text](url), images , lists (- item or 1. item), code blocks (```lang), inline code (`code`), blockquotes (> quote), tables (| col |), strikethrough (~~text~~), and task lists (- [ ] task).
- How do I convert HTML to Markdown?
- Select "HTML to Markdown" mode, paste HTML code, and click Run. The tool converts common HTML elements: <h1>→# , <strong>** , <em>* , <a>[]() , <ul>/<li>→- , <code>→` `. Complex HTML (nested divs, CSS classes, JavaScript) may not convert cleanly—Markdown is simpler than full HTML.
- What is the difference between Markdown and HTML?
- Markdown is a subset of HTML focused on readability. Markdown uses intuitive symbols (# for headings, ** for bold) while HTML uses verbose tags (<h1>, <strong>). Markdown converts to HTML for web display. Use Markdown for writing; use HTML when you need precise control over styling, layout, or interactivity.
- How do I create tables in Markdown?
- Markdown tables use pipes (|) and dashes (-): first row is header, second row defines alignment with colons, subsequent rows are content. Example: | Header | --- | align |. Not all Markdown parsers support tables—GitHub Flavored Markdown does, but basic CommonMark doesn't.
- Can I embed images and videos in Markdown?
- Images use  syntax. Videos aren't natively supported in standard Markdown—use HTML <video> tags or platform-specific embeds (YouTube:  linking to video). For responsive images, you need HTML or platform extensions.