Convert Markdown to clean HTML. Runs entirely in your browser.
$1โ);
// Headings
html = html.replace(/^######\s+(.+)$/gm, โ$1
โ); html = html.replace(/^#####\s+(.+)$/gm, โ$1
โ); html = html.replace(/^####\s+(.+)$/gm, โ$1
โ); html = html.replace(/^###\s+(.+)$/gm, โ$1
โ); html = html.replace(/^##\s+(.+)$/gm, โ$1
โ); html = html.replace(/^#\s+(.+)$/gm, โ$1
โ); // Bold and italic html = html.replace(/***(.+?)***/g, โ$1โ); html = html.replace(/**(.+?)**/g, โ$1โ); html = html.replace(/*(.+?)*/g, โ$1โ); // Images html = html.replace(/![([^]])](([^)]+))/g, '$1โ); // Horizontal rules html = html.replace(/^---$/gm, '
'); // Unordered lists html = html.replace(/^[-*]\s+(.+)$/gm, โ
- $1
$1
โ); // Clean up empty paragraphs html = html.replace(/\s*</p>/g, โ); return html.trim(); } function convertMd() { var md = document.getElementById(โmd-inputโ).value; var html = mdToHtml(md); document.getElementById(โmd-htmlโ).value = html; document.getElementById(โmd-previewโ).innerHTML = html; } function togglePreview() { document.getElementById(โmd-preview-wrapโ).style.display = document.getElementById(โmd-show-previewโ).checked ? โblockโ : โnoneโ; } function copyMdHtml(btn) { navigator.clipboard.writeText(document.getElementById(โmd-htmlโ).value); btn.textContent = โCopied!โ; setTimeout(function() { btn.textContent = โCopy HTMLโ; }, 1500); } document.getElementById(โmd-inputโ).addEventListener(โinputโ, convertMd);
Supported Syntax
- Headings (
# H1through###### H6) - Bold (
**text**) and italic (*text*) - Links (
[text](url)) and images () - Code blocks (triple backticks) and inline code
- Unordered and ordered lists
- Blockquotes (
> text) - Horizontal rules (
---)
For a full reference, see the Markdown Cheat Sheet.