Markdown 转 HTML

将 Markdown 转换为干净的 HTML,支持富文本编辑、实时预览和可自定义的转换选项。非常适合开发者和内容创作者。

快速参考

# Heading 标题
**bold** 加粗
*italic* 斜体
[text](url) 链接
- item 列表
`code` 代码

定义: CommonMark 是一份完整、无歧义的 Markdown 规范:块级构造(标题、列表、围栏代码块)与行内片段(强调、链接、代码)直接映射到 HTML 元素。

CommonMark 规范 最后更新: 2026-11

如何使用 Markdown 转 HTML 转换器

1

输入 Markdown

在输入区输入或粘贴 Markdown

2

自动转换

开启自动转换,即时生成 HTML

3

预览

在代码视图和实时预览之间切换

4

导出

复制 HTML,或下载为完整的 .html 文件

理解 Markdown 转 HTML

什么是 Markdown 转 HTML?

Markdown 转 HTML 可将简单的 Markdown 文本转换为格式正确的 HTML 标记。这让您以便于阅读的格式编写内容,并发布为可直接上线的 HTML。

  • • 简洁语法: 易于书写的格式语法
  • • 整洁 HTML: 语义化、符合标准的输出
  • • 实时预览: 边输入边查看结果
  • • 完整支持: 标题、列表、链接、代码块

为什么使用 Markdown 转 HTML?

Markdown 非常适合在不处理复杂 HTML 标签的情况下编写内容。将您的笔记、文档或博客文章转换为 HTML 以便在网络上发布。

  • • 轻松写作: 专注内容而非语法
  • • 网页发布: 为网站创建 HTML
  • • 邮件模板: 生成 HTML 邮件
  • • 文档: 把 README 文件转换为网页

实时预览

在代码视图和渲染预览之间切换,精确查看内容最终的呈现效果。

100% 隐私

所有转换均在本地完成。您的 Markdown 绝不会被发送到任何服务器。

完全免费

无需注册,没有限制。无限量地将 Markdown 转换为 HTML,永久免费。

使用文本分析和格式化工具提高您的工作效率

`; const blob = new Blob([fullHtml], { type: 'text/html' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'converted.html'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } function clearAll() { const markdownInput = document.getElementById('markdown-input'); markdownInput.value = ''; markdownInput.dispatchEvent(new Event('input', { bubbles: true })); document.getElementById('html-output').value = ''; updateInputPreview(); updateOutputPreview(); } // 文本草稿(O2 批量):编辑即存、回访恢复。须在 OhMonaco.attach 之前执行——Monaco 以 textarea 值初始化; // Monaco 同步链路会向 textarea 派发 input 事件,故存草稿挂 textarea 一处即可覆盖编辑器/纯文本双模式。隐私模式静默降级。 (function () { var KEY = 'ohtb:markdown-to-html:draft'; var textarea = document.getElementById('markdown-input'); if (!textarea) return; try { var draft = localStorage.getItem(KEY); if (draft) textarea.value = draft; } catch (e) { /* 静默 */ } var timer = null; textarea.addEventListener('input', function () { clearTimeout(timer); timer = setTimeout(function () { try { if (textarea.value) localStorage.setItem(KEY, textarea.value); else localStorage.removeItem(KEY); } catch (e) { /* 静默 */ } }, 300); }); // 页面各监听器就位后再等价触发一次 input,让统计/转换对已恢复草稿生效 document.addEventListener('DOMContentLoaded', function () { // 延后一拍:等页面在 DOMContentLoaded 里绑定的统计/转换监听就位后再触发 setTimeout(function () { if (textarea.value) textarea.dispatchEvent(new Event('input', { bubbles: true })); }, 0); }); })(); document.addEventListener('DOMContentLoaded', function() { const markdownInput = document.getElementById('markdown-input'); const auto = document.getElementById('auto-convert'); markdownInput.addEventListener('input', function () { if (auto.checked) { convert(); } }); if (window.OhMonaco) { window.OhMonaco.attach({ textareaId: 'markdown-input', containerId: 'markdown-input-editor', toggleId: 'markdown-to-html-monaco-toggle', themeSelectId: 'markdown-to-html-monaco-theme', language: 'markdown', onChange: () => { if (auto.checked) { convert(); } }, }); } const monacoToggle = document.getElementById('markdown-to-html-monaco-toggle'); if (monacoToggle) { monacoToggle.addEventListener('change', function () { setTimeout(() => { if (inputMode === 'edit') { applyModeUI(); } }, 0); }); } convert(); applyModeUI(); });