October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk7 min

How to Convert a Web Page to Markdown: A Developer’s Guide

A practical guide to converting web pages to Markdown: separate fetching from extraction and conversion, choose a JavaScript, Python, or URL workflow, and check the result.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Converting a web page to Markdown is a three-stage job: fetch the page, isolate the content you want, then convert its HTML structure. If you already have an HTML string or DOM node, a converter such as Turndown can serialize it. If you have a live URL, you also need a fetching step—and possibly a browser to render JavaScript-dependent content. Choose the workflow based on which of those inputs you have.

Choose the right conversion workflow

HTML-to-Markdown conversion and main-content extraction are separate tasks. A converter processes the HTML you give it; that does not mean it can reliably recognize the article body on every site. Decide first whether you are starting with a URL, a complete fetched document, or an article fragment already separated from navigation and other page elements.

Approach Best-supported use Consider
Turndown Convert an HTML string or DOM in a JavaScript workflow. Whether HTML is already available and whether you need custom conversion rules. Its documentation describes an HTML-to-Markdown converter, not a universal article extractor.
Microsoft MarkItDown Convert HTML in a Python workflow that may also handle other document types. Python environment, supported inputs, and process permissions. Its project is aimed at preserving structure for text analysis and notes it may not suit high-fidelity, human-facing conversion.
Hosted URL conversion API Submit a public URL to a managed service that fetches and converts it. Whether you need browser rendering, account credentials, a subscription, credits, or asynchronous processing. Details are specific to each provider and can change.

These are workflow distinctions, not a comparative quality ranking. The available package and product documentation does not establish an accuracy score or prove that any option produces a perfect, lossless result.

Convert HTML with Turndown in JavaScript

Use Turndown when your JavaScript application already has the HTML or DOM to convert. Install the package, pass it the HTML, and inspect the resulting Markdown. This example reads a local HTML file, so it does not fetch a live page or extract its main article automatically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Install Turndown in your project with npm install turndown.

  2. Save the HTML you want to convert as page.html.

  3. Run this Node.js example:

    const fs = require('node:fs');
    const TurndownService = require('turndown');
    
    const html = fs.readFileSync('page.html', 'utf8');
    const turndown = new TurndownService();
    const markdown = turndown.turndown(html);
    
    fs.writeFileSync('page.md', markdown, 'utf8');
    console.log('Wrote page.md');

Turndown documents configurable rules, which can help adapt serialization to your content. Do not treat custom rules as a substitute for selecting the right content: if you pass a full page, navigation, banners, and footers may also be converted. For a fetched page, your application must obtain the HTML separately and decide how to handle JavaScript-rendered content.

Convert HTML with Microsoft MarkItDown in Python

MarkItDown is a Python option when HTML conversion belongs in a broader document-to-Markdown workflow. Its README lists Python 3.10 through 3.14 and recommends a virtual environment; verify current compatibility and installation instructions in the project repository because supported versions and setup can change.

  1. Create and activate a virtual environment, then install the package and HTML-related dependencies using the documented extra:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    python -m venv .venv
    # macOS or Linux:
    source .venv/bin/activate
    # Windows PowerShell:
    .venvScriptsActivate.ps1
    
    python -m pip install 'markitdown[all]'
  2. Convert an HTML file from the command line and write the Markdown output to a file:

    markitdown page.html > page.md

The project also documents Python usage. Check the current README for the supported interface and options rather than assuming a particular command or API will remain unchanged. MarkItDown describes its focus as preserving document structure for text analysis; choose another approach if your requirement is a carefully curated, human-facing article representation.

When the input is a live URL

A URL is not the same input as an HTML document. A plain HTTP request can retrieve server-delivered HTML, but it will not necessarily include content that the page adds later with client-side JavaScript. If the page depends on browser execution, use a browser-rendering stage or a service that explicitly supports rendering.

For example, markitdown.ai documents a URL conversion endpoint, POST /v1/convert/url, and vendor-specific render modes: auto, force, and skip. Its documentation says auto renders when fetched HTML has no readable content. That behavior describes this service only; it should not be assumed of Turndown, MarkItDown, or other URL converters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The same service documentation describes API-key authentication, an active-subscription requirement for conversion requests, page-based credits, and requests that may finish synchronously or return an asynchronous job to poll or follow by webhook. Its overview lists standard and OCR pages at 1 credit per page and AI image understanding at 5 credits per image for paid-plan accounts. Those are provider-published terms, not general properties of URL conversion; confirm the current endpoint, authentication, credit rules, and async workflow in the URL conversion documentation and API overview before building around them.

Extract the content before converting

If the goal is an article rather than a record of the entire page, isolate the meaningful content before serialization. Depending on the source, that may mean selecting an article container, removing navigation and overlays, or using a site-specific content rule. Test against representative pages from the actual domain: page structures vary, and HTML conversion alone does not establish that the right content was selected.

Review relative links as well. A Markdown link such as [Details](../details) depends on its original base URL; if the Markdown will be stored elsewhere, resolve relative URLs to absolute URLs or preserve the source page URL alongside the document.

Review the Markdown output

Compare the result with the source page before treating it as complete. Markdown represents some layouts less naturally than HTML, and dynamic content may never have been present in the input you converted.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Headings: Confirm that heading levels remain meaningful and do not jump because page chrome was included.
  • Lists and code: Check nesting, ordered-list numbering, inline code, and fenced code blocks.
  • Links and images: Verify destinations, relative URL handling, alt text, and whether images are actually needed in the Markdown output.
  • Tables: Inspect complex or merged-cell tables; Markdown table syntax cannot represent every HTML table structure.
  • Metadata and dynamic content: Decide whether titles, descriptions, captions, or content added after initial page load belong in the final document.

Package documentation describes intended structural handling, but the available sources do not provide comparative conversion-accuracy measurements. Treat review as ordinary quality control rather than relying on an unverified claim of perfect conversion.

Protect server-side conversion jobs

Conversion code that accepts user-controlled files or URLs can expose the permissions of the process running it. Microsoft’s MarkItDown README warns that it performs I/O using the current process’s privileges. For an untrusted or hosted workflow, validate inputs, restrict allowed paths and URL schemes, constrain network destinations, and use the narrowest conversion interface that meets the task. Those measures are important safeguards, not a complete security review.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common conversion problems

The output contains navigation, cookie notices, or a footer

The converter likely received the whole page instead of the article fragment. Identify and isolate the content container before converting, then check whether a banner or other overlay is part of the supplied HTML.

The result is empty or missing text

Check that the input contains the expected HTML and that the content was present at fetch time. If a page inserts its text with JavaScript, a basic fetch may not contain it; use a browser-rendering step or a URL service with a documented rendering mode.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Links point to the wrong place

Inspect whether source links were relative. Resolve them against the original page URL if the Markdown will be consumed outside its original context.

Tables or layout do not survive cleanly

Markdown cannot express every HTML layout or table feature. Simplify the selected content where appropriate, retain a link to the original page, or keep an HTML representation when preserving complex structure matters more than Markdown readability.

A server-side job can reach unintended resources

Do not pass arbitrary paths or URLs to a process with broad filesystem or network permissions. Apply input validation and destination restrictions before conversion, following the security warning in the MarkItDown documentation.

Or skip the browser setup

If you need a screenshot or PDF of a live page rather than Markdown text, ScreenshotNeo is a website screenshot API and MCP server. It does not replace HTML-to-Markdown conversion; it fits when the desired output is a visual capture. For a one-call screenshot, see the API documentation:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The Free plan includes 1,000 screenshots a month without a card; paid plans start at $5 for 3,000 shots.

Sign up free for 1,000 screenshots a month—no card required.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.