# Converting HTML and web pages to Markdown with MarkItDown

> MarkItDown 0.1.9 on web pages: what HTML is kept or stripped, why a URL can return 403, redirects, PDFs over HTTP, JavaScript pages and fetching pages yourself.

Source: https://markitdown.dev/formats/html/ · Updated 2026-11-16·Upstream source ↗

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:
> 
> ```bash
> 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](https://markitdown.dev/data/web-sources.csv), [static-article-local-server.md](https://markitdown.dev/evidence/T20/outputs/static-article-local-server.md), [article-main-only.md](https://markitdown.dev/evidence/T20/outputs/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:

````markdown
[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*

-   **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:

````markdown
# 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*

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)
| Case | Worked | Characters | Result |
| --- | --- | --- | --- |
| static article (local server) | yes | 613 | `[Home](https://example.org/) [News](https://example.org/news/) [About](https://example.org` |
| JavaScript-rendered shell | yes | 10 | `Loading...` |
| redirect to the article | yes | 613 | `[Home](https://example.org/) [News](https://example.org/news/) [About](https://example.org` |
| 404 page | no | 0 | `HTTPError: 404 Client Error: Not Found for url: http://127.0.0.1:49149/missing` |
| PDF served over HTTP | yes | 926 | `Pilot Report: Field Station Alpha 1. Summary Rainfall across the three stations rose stea` |
| RSS feed over HTTP | yes | 30 | `# Rain feed ## Item one First` |
| site that refuses python-requests (403) | no | 0 | `HTTPError: 403 Client Error: Forbidden for url: http://127.0.0.1:49149/blocked` |
| request headers the converter sends | yes | 104 | `Accept header: text/markdown, text/html;q=0.9, text/plain;q=0.8, \*/\*;q=0.1 UA: python-r` |
| Wikipedia article, desktop address | no | 0 | `HTTPError: 403 Client Error: Forbidden for url: https://en.wikipedia.org/wiki/Markdown` |
| Wikipedia article, mobile address | no | 0 | `HTTPError: 403 Client Error: Forbidden for url: https://en.m.wikipedia.org/wiki/Markdown` |
| example.com | yes | 156 | `This 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 bytes | yes | 613 | `[Home](https://example.org/) [News](https://example.org/news/) [About](https://example.org` |
| blocked site, your own requests.Session passed to MarkItDown | yes | 613 | `[Home](https://example.org/) [News](https://example.org/news/) [About](https://example.org` |
| article page: whole page against only the <main> element | yes | 613 | `main 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.

## Related

- [Supported formats](https://markitdown.dev/formats/): Every file type MarkItDown converts.
- [Python API guide](https://markitdown.dev/python-api/): The Python API, including your own HTTP session.
- [Error reference](https://markitdown.dev/errors/): Error messages.
- [CSV, JSON, XML, text](https://markitdown.dev/formats/csv-json-xml/): CSV, JSON and XML.

---
Independent guide to the open-source MarkItDown library. Not affiliated with or endorsed by Microsoft. Official source: https://github.com/microsoft/markitdown
