Skip to content
cosmodev ~/tools/html-to-markdown

Trình chuyển đổi HTML → Markdown

Converters & Formatters

Chuyển đổi các đoạn HTML và bài viết thành Markdown sạch: tiêu đề, nhấn mạnh, liên kết, hình ảnh, danh sách, trích dẫn và khối mã, tất cả được xử lý cục bộ trong trình duyệt của bạn kèm liên kết chia sẻ.

Thử:

(Tài liệu bằng tiếng Anh)

What it does

Converts HTML into clean Markdown: headings, paragraphs, bold/italic/strikethrough, inline code, links (with optional titles), images, ordered and unordered lists with nesting, block quotes, horizontal rules and fenced code blocks (language detected from class="language-…"). It is forgiving by design: unclosed tags auto-close, stray closing tags are ignored, unknown tags pass their content through, and HTML entities are decoded. Literal Markdown characters in your text (*, _, [, ], `) are backslash-escaped so they cannot masquerade as formatting. Everything runs locally in your browser — no DOM needed, the parser is hand-rolled.

How to use it

  1. Paste HTML into HTML (left), or tap a chip — Fragment, Lists, Rich article. Sample loads a full article; Clear empties the box.
  2. The Markdown appears live in Markdown output (right).
  3. Copy takes the document.
  4. Copy share link encodes your input in the URL.

Examples

Inline marks:

<p>Some <strong>bold</strong> and <em>italic</em> with a <a href="https://x.dev">link</a>.</p> → Some **bold** and *italic* with a [link](https://x.dev).

Nested list:

<ul><li>a<ul><li>b</li></ul></li></ul> → - a + newline + - b

Code with a language:

<pre><code class="language-js">const a = 1;</code></pre> → a ```js fence.

Escaping: <p>3 * 4 [x]</p> → 3 \* 4 \[x\] — the characters survive as text.

How the conversion works

The parser builds a tree first (strings, comments and tags are told apart in one scan), then renders blocks — headings, quotes, lists, fences get blank-line separation, while inline marks nest inside. Two deliberate rules keep the output honest:

Input Behavior
Unclosed <p>a at EOF auto-closed, converted
Stray </b> with no opener ignored
<span>, unknown tags transparent — children converted
<h3> with text after it in one chunk heading, then the text as a paragraph
Empty <strong></strong> renders as nothing (empty emphasis is invalid Markdown)
< with no closing > the one error: “Unclosed tag”

For the other direction, use Markdown to HTML Converter.

Mã nguồn14 ngôn ngữ

100% phía client · dữ liệu của bạn không bao giờ rời khỏi trình duyệt. Thấy hữu ích? Chia sẻ với đồng nghiệp của bạn.