New1 billion tokens free on sign-up — crawl, parse, chunk and embed on the houseSee pricing
SarvCrawlSarvCrawl

Glossary · Extraction and parsingUpdated

What is HTML to Markdown conversion?

HTML to Markdown conversion turns a web page’s markup into Markdown, a lightweight plain-text format that keeps headings, lists, links, tables and code while dropping tags, attributes and styling. It is a common way to prepare web content for LLMs and search.

01HTML to Markdown in more depthof 06

HTML to Markdown in more depth

Raw HTML carries a lot that a reader never sees: class attributes, inline styles, tracking scripts, nested <div> wrappers. For a language model every one of those characters is a token, and for a search index it is noise. Plain text goes too far the other way, flattening headings and tables so structure is lost.

Markdown sits in between. A heading is still a heading (## Pricing), a list is still a list, a link keeps its URL, and a table keeps its rows. That structure is exactly what document chunking uses to split content at sensible boundaries.

How conversion works

  1. Parse the HTML into a DOM tree.
  2. Optionally reduce it to the main content first; see main content extraction.
  3. Walk the tree and map each element to Markdown syntax.
  4. Resolve relative links and image paths against the page URL.
  5. Clean up whitespace and escape characters that Markdown would misread.
HTMLMarkdown
<h2>Setup</h2>## Setup
<strong>, <em>**bold**, *italic*
<a href="/docs">Docs</a>[Docs](https://site.com/docs)
<ul><li>- item
<pre><code>fenced code block
<table>pipe table (GitHub-flavoured Markdown)

Example

## Install

Run the installer, then check the version:

```bash
pip install sarvcrawl
```

| Flag    | Meaning        |
| ------- | -------------- |
| `-q`  | Quiet output   |

See the [quick start](https://example.com/docs/quickstart).

The same content as rendered HTML is typically several times longer once wrappers and attributes are counted. You can compare on your own pages with the HTML to markdown tool.

Common pitfalls

  • Complex tables. Merged cells (rowspan, colspan) and nested tables have no Markdown equivalent and come out flattened or garbled.
  • Layout tables and divs used for visual grids can turn into meaningless runs of text.
  • Converting the chrome. Without content extraction, every page starts with the same menu and ends with the same footer.
  • Relative links left unresolved, which break once the text leaves the site.
  • Images. Alt text survives; the information in a chart or diagram does not.

How SarvCrawl handles it

Markdown is the default output of every scrape and crawl. Pages are rendered in a real browser first, so client-side content is included, and main-content extraction strips nav, footer, aside, script and style before conversion. The same pipeline parses uploaded PDFs, Office files, EPUBs and images into markdown, with OCR for scanned PDFs and a conversion audit that scores each conversion. The markdown is then chunked and embedded into a knowledge base. For one page at a time, use the free HTML to markdown or PDF to markdown tools.

Frequently asked questions

Why convert HTML to Markdown for LLMs?

Markdown keeps headings, lists, tables and links but drops tags and attributes, so the same content uses far fewer tokens and is easier for the model to follow.

Does Markdown keep tables?

Simple tables, yes, as pipe tables. Tables with merged or nested cells cannot be represented exactly and usually need simplifying.

Should I strip navigation before converting?

Usually. Navigation and footers repeat on every page and add noise to search and model context. Keep them only when the navigation itself is the content you need.

SarvCrawl

Turn any site into a searchable knowledge base

Crawl pages and parse documents into clean markdown, then chunk, embed and search them from one API.