Formats

Converting HTML and web pages to Markdown with MarkItDown

Updated 2026-11-16·Upstream source ↗
Markdown view

Give MarkItDown an HTML file or a web address and it converts the whole page body to Markdown, menus and footer included. It fetches like a script, not like a browser: it runs no JavaScript and some sites refuse the request. We tested these cases on a local server we control, plus two real addresses.

Short answer

No extra is needed:

Command
markitdown https://example.com

Clean structure from real HTML, no main-content extraction, no JavaScript. A page that refuses scripts fails with an HTTP error, as Wikipedia did for us.

Tested with markitdown 0.1.9 · Python 3.13 · markitdown 0.1.9 · a local test server for most cases, plus two real addresses from a cloud lab network (T20). One small test page, so size figures are illustrative · 2026-11-16 · evidence: web-sources.csv, static-article-local-server.md, article-main-only.md

What is kept, changed and dropped

Our test page has navigation, a cookie notice, an article with a table, nested list, code block, image and links, and a footer. This is what MarkItDown wrote:

The whole page
[Home](https://example.org/) [News](https://example.org/news/) [About](https://example.org/about)

We use cookies. Accept

# Spring rainfall rose 12%

Three stations reported **steady** rain; see the [data](https://example.org/data/table.csv) and [the source](https://example.org/x).

## Key points

* Uptime reached 99.2%
  + nested item
* Two stations need batteries

| Station | Rain (mm) |
| --- | --- |
| Alpha | 412.5 |
| Bravo | 388.0 |

```
print("hello")
```

![Bar chart of rain](https://example.org/img/chart.png)

Text with an inline `code` span.

Copyright 2026 Example · Privacy · Terms · Contact us
static-article-local-server.md · 616 bytes output (.md)
  • Kept: headings, bold, links, nested lists, a table with its header row, an image as ![alt](src), inline code.
  • Changed: the code block's language class (language-python) was dropped from the fence.
  • Dropped: the <script> and <style> content. The navigation, cookie notice and footer text stayed.

There is no "main content" mode

On our small test page, 29% of the output (178 of 613 characters) was navigation, cookie text and footer. We measured only this one page, so real news pages will differ. Passing only the <main> element to MarkItDown removes it:

Only the main element
# Spring rainfall rose 12%

Three stations reported **steady** rain; see the [data](https://example.org/data/table.csv) and [the source](https://example.org/x).

## Key points

* Uptime reached 99.2%
  + nested item
* Two stations need batteries
article-main-only.md · 435 bytes · first 10 of 22 lines shown output (.md)

You select the element yourself with an HTML parser, or use a readability-style extractor first; we did not test one. For language-model use, the boilerplate is often acceptable.

Converting a URL

Each address through MarkItDown 0.1.9 (the Python API)
CaseWorkedCharactersResult
static article (local server)yes613[Home](https://example.org/) [News](https://example.org/news/) [About](https://example.org
JavaScript-rendered shellyes10Loading...
redirect to the articleyes613[Home](https://example.org/) [News](https://example.org/news/) [About](https://example.org
404 pageno0HTTPError: 404 Client Error: Not Found for url: http://127.0.0.1:49149/missing
PDF served over HTTPyes926Pilot Report: Field Station Alpha 1. Summary Rainfall across the three stations rose stea
RSS feed over HTTPyes30# Rain feed ## Item one First
site that refuses python-requests (403)no0HTTPError: 403 Client Error: Forbidden for url: http://127.0.0.1:49149/blocked
request headers the converter sendsyes104Accept header: text/markdown, text/html;q=0.9, text/plain;q=0.8, \*/\*;q=0.1 UA: python-r
Wikipedia article, desktop addressno0HTTPError: 403 Client Error: Forbidden for url: https://en.wikipedia.org/wiki/Markdown
Wikipedia article, mobile addressno0HTTPError: 403 Client Error: Forbidden for url: https://en.m.wikipedia.org/wiki/Markdown
example.comyes156This domain is for use in documentation examples without needing permission. This is not a
blocked site, fetched with your own client then converted from the bytesyes613[Home](https://example.org/) [News](https://example.org/news/) [About](https://example.org
blocked site, your own requests.Session passed to MarkItDownyes613[Home](https://example.org/) [News](https://example.org/news/) [About](https://example.org
article page: whole page against only the <main> elementyes613main only: 435 characters; boilerplate share 29%
Each address through MarkItDown 0.1.9 (the Python API) Source: Test T20 · 2026-11-15 and 2026-11-16 · local server and two real addresses · web-sources.csv · Download CSV

What the table shows:

  • A redirect was followed. A PDF served over HTTP converted as a PDF. An RSS feed converted to a title and items.
  • A JavaScript-rendered page gave only its placeholder text (Loading...): the script did not run.
  • A 404 raised HTTPError, as did a 403.
  • The converter sends Accept: text/markdown, text/html;q=0.9, text/plain;q=0.8, */*;q=0.1 and the identity of the requests library.

403 Forbidden

en.wikipedia.org and en.m.wikipedia.org both answered MarkItDown's request with 403 from our network. Sites refuse the default script identity for their own reasons, and we are not going to document ways around a site's access rules. Legitimate routes:

  1. Use the site's API where it has one (Wikipedia does).
  2. Fetch the page yourself with an HTTP client under conditions the site allows, then hand MarkItDown the bytes: convert_stream(stream, file_extension=".html"). On our local server this converted the same page that the default request could not (613 characters).
  3. Pass your own requests.Session, with whatever headers you are allowed to send, to MarkItDown(requests_session=...). This worked in the same local test.

We did not test Wikipedia's dedicated converter, because we could not fetch the pages.

JavaScript-rendered pages

You get the page's initial HTML. Render the page in a browser you control, save the HTML, and convert that file. We did not test this procedure.

Not tested

Search-result pages, cookie-wall pages on real sites, pages in other encodings, very large pages, and the Wikipedia converter.