ETEvoraTools
Markdown & Document Tools

HTML to Markdown Converter

HTML to Markdown Converter maps h1–h6, list items, strong/b, em/i, code, anchors, br, and paragraphs to basic Markdown, then strips remaining tags and decodes a short entity list. It is a textual convenience converter rather than an HTML parser, so nesting, malformed markup, tables, images, scripts, attributes, and exact whitespace can be lost.

Runs locally — files stay on your device
Quick answer

Will HTML round-trip perfectly through this converter?

No. Markdown cannot represent every HTML structure, and this implementation supports only a small element subset.

HTML-to-Markdown conversion is inherently lossy

HTML expresses a rich element tree with attributes and browser parsing rules. Basic Markdown covers fewer structures, so conversion needs a policy for unsupported information.

How it works

Regular-expression replacements translate supported paired tags and links, line breaks become newlines, unsupported tags are removed, and a few named entities are decoded.

Key concepts

Tag removal is not sanitization

Security depends on the final parser and output context, not this string conversion.

Structure can collapse

Nested blocks and unsupported elements may become plain adjacent text.

When to use it

  • Simplify a controlled HTML fragment.
  • Convert common headings and emphasis.
  • Create a Markdown starting point for manual cleanup.

When not to use it

  • Do not process arbitrary malformed HTML as if browser parsing were reproduced.
  • Do not expect tables, images, attributes, or semantic containers to survive.
  • Do not use it as an HTML sanitizer.

Worked examples

Heading

Input
<h2>Setup</h2>
Expected output
## Setup

Heading level is retained.

Link

Input
<a href="https://example.com">Example</a>
Expected output
[Example](https://example.com)

The href and visible text are mapped.

Image

Input
<img src="a.png" alt="A">
Expected output
Removed

Image conversion is not implemented.

Common mistakes

Calling it a DOM parser

Browser tree-construction rules are not used. Correction: Use an HTML parser for arbitrary markup.

Expecting attributes

Classes, ids, data attributes, and styles disappear. Correction: Preserve metadata separately.

Using output as sanitized content

String rewriting is not a security guarantee. Correction: Sanitize for the final rendering context.

Best practices

  • Use controlled input.
  • Compare the result with the original structure.
  • Run manual cleanup or a mature conversion library for publication.

Related operations and differences

Markdown to HTML Converter

Choose Markdown to HTML Converter when you need to convert Markdown headings, emphasis, links and lists to HTML.; use HTML to Markdown Converter specifically for html markdown.

Document Link Extractor

Choose Document Link Extractor when you need to extract labeled links from Markdown or HTML.; use HTML to Markdown Converter specifically for html markdown.

CSV to Markdown Table

Choose CSV to Markdown Table when you need to turn comma-separated rows into a Markdown table.; use HTML to Markdown Converter specifically for html markdown.

Document Word Statistics

Choose Document Word Statistics when you need to measure words, characters, lines and reading time.; use HTML to Markdown Converter specifically for html markdown.

HTML to Plain Text

Choose HTML to Plain Text when you need to remove markup, scripts and styles from HTML.; use HTML to Markdown Converter specifically for html markdown.

Inline Links to Footnotes

Choose Inline Links to Footnotes when you need to convert parenthesized URLs into numbered footnotes.; use HTML to Markdown Converter specifically for html markdown.

Limitations and privacy

  • Small element subset.
  • No DOM parsing, tables, images, lists containers, attributes, or comprehensive entity decoding.
  • Whitespace and nesting can change.

Document text is transformed locally in this browser.

Frequently asked questions

Are scripts safely sanitized?

This is not a sanitizer.

Are images converted?

No.

Are classes retained?

No.

Does malformed HTML follow browser rules?

No.

References