Skip to content

Python URL to Markdown API

Convert any URL to clean, LLM-ready markdown with one HTTP request in Python — no Playwright, no readability pipeline, no browser to maintain.

Convert a URL to markdown in Python

No package and no browser — the Microlink REST API turns any URL into clean markdown with a single HTTP GET. Here it is with urllib and json from the Python standard library.
Step 01 · Convert any URL
A few lines with the standard library — no pip install to run. Point it at a page and read the markdown string from the JSON response.
convert.py
import json
import urllib.parse
import urllib.request

params = urllib.parse.urlencode({
    'url': 'https://example.com',
    'data.markdown.attr': 'markdown',
    'meta': 'false',  # skip metadata extraction for a faster response
})

with urllib.request.urlopen(f'https://api.microlink.io?{params}') as res:
    data = json.load(res)['data']

print(data['markdown'])
Step 02 · Scope the extraction
Pass a CSS selector to keep just the article body and drop headers, footers, and sidebars — fewer tokens, better embeddings.
scoped.py
import json
import urllib.parse
import urllib.request

params = urllib.parse.urlencode({
    'url': 'https://example.com/blog/post',
    'data.markdown.attr': 'markdown',
    'data.markdown.selector': 'article',  # keep just the article body
    'meta': 'false',
})

with urllib.request.urlopen(f'https://api.microlink.io?{params}') as res:
    data = json.load(res)['data']

print(data['markdown'])
Step 03 · Render JavaScript pages
Client-side rendered content only exists after JavaScript runs — prerender with a real browser and wait for the content, still one request.
spa.py
import json
import urllib.parse
import urllib.request

params = urllib.parse.urlencode({
    'url': 'https://app.example.com/docs',
    'data.markdown.attr': 'markdown',
    'data.markdown.selector': 'main',
    'prerender': 'true',          # render JS in a real browser first
    'waitForSelector': 'main h1',  # wait until the content exists
    'meta': 'false',
})

with urllib.request.urlopen(f'https://api.microlink.io?{params}') as res:
    data = json.load(res)['data']

print(data['markdown'])
Step 04 · Get markdown back directly
Skip the JSON envelope entirely: embed=markdown returns the page as text/markdown, ready to write into a file or a prompt.
embed.py
import urllib.parse
import urllib.request

params = urllib.parse.urlencode({
    'url': 'https://example.com',
    'data.markdown.attr': 'markdown',
    'meta': 'false',
    'embed': 'markdown',  # respond with text/markdown instead of JSON
})

with urllib.request.urlopen(f'https://api.microlink.io?{params}') as res:
    markdown = res.read().decode('utf-8')

with open('page.md', 'w') as f:
    f.write(markdown)

Drop it into your framework

A FastAPI route, a Flask endpoint, or a LlamaIndex reader — the same request becomes your own URL-to-markdown primitive for agents and RAG pipelines.
  • FastAPI
  • Flask
  • LlamaIndex
  • Plain Python
import json
import urllib.parse
import urllib.request

from flask import Flask, request, Response

app = Flask(__name__)

# GET /markdown?url=https://example.com
@app.get('/markdown')
def markdown():
    params = urllib.parse.urlencode({
        'url': request.args['url'],
        'data.markdown.attr': 'markdown',
        'meta': 'false',
    })

    with urllib.request.urlopen(f'https://api.microlink.io?{params}') as res:
        data = json.load(res)['data']

    return Response(data['markdown'], mimetype='text/markdown')

Skip the readability pipeline maintenance

Rolling your own means fetching HTML, running readability-lxml, converting with markdownify, and adding Playwright when a page needs JavaScript. The API gives you clean markdown from any page without any of the moving parts.

DIY extraction pipeline

  • Fetch HTML, then chain readability-lxml + markdownify yourself
  • Every site breaks your selectors in its own special way
  • JavaScript-rendered pages need Playwright — a 300 MB browser
  • Each browser eats hundreds of MB of RAM per worker
  • You build the queueing, retries, caching and autoscaling
  • Output quality drifts as sites change; you own the fixes

Microlink for Python

  • One HTTP request — urllib from the standard library, no pip install
  • Runs anywhere: AWS Lambda, Modal, containers, your laptop
  • Real browser rendering built in with prerender=true
  • CSS selector scoping keeps tokens focused on the content
  • Cached responses from a global edge network
  • Autoscaled fleet with a 99.95% uptime SLA

Built for the way you write Python.

A REST API that feels native in Python — one call, JSON back, and at home in anything from a notebook to a worker fleet. Read the URL to Markdown guide to go deeper.

  • No Browser to Install

    No Playwright or Selenium to install or keep patched. JavaScript rendering runs on Microlink’s side with prerender=true.
  • Standard Library Only

    urllib and json ship with Python — the examples run with zero pip installs and nothing to vendor.
  • LLM-Ready Output

    Clean markdown instead of HTML noise — around 80% fewer tokens on average, so agents spend context on meaning, not markup.
  • CSS Selector Scoping

    Extract the whole page or narrow to article, main, or any selector — precise content targeting for better embeddings.
  • JavaScript Rendering

    SPAs and client-rendered docs are rendered in a real browser first, with waitForSelector to catch late content.
  • Documents Too

    Point it at a PDF or an office file — docx, xlsx, pptx — and the content is converted to markdown the same way.
  • Framework Friendly

    Drop it into FastAPI, Flask, or a LlamaIndex reader as a route or a few-line function.
  • text/markdown Responses

    embed=markdown returns the page as text/markdown — write it straight into a file, a queue, or a prompt.
  • Generous Free Tier

    Start with 25 requests per day — no account, no credit card. Add an API key when you are ready to scale.
  • No Browser to Install

    No Playwright or Selenium to install or keep patched. JavaScript rendering runs on Microlink’s side with prerender=true.
  • Standard Library Only

    urllib and json ship with Python — the examples run with zero pip installs and nothing to vendor.
  • LLM-Ready Output

    Clean markdown instead of HTML noise — around 80% fewer tokens on average, so agents spend context on meaning, not markup.
  • CSS Selector Scoping

    Extract the whole page or narrow to article, main, or any selector — precise content targeting for better embeddings.
  • JavaScript Rendering

    SPAs and client-rendered docs are rendered in a real browser first, with waitForSelector to catch late content.
  • Documents Too

    Point it at a PDF or an office file — docx, xlsx, pptx — and the content is converted to markdown the same way.
  • Framework Friendly

    Drop it into FastAPI, Flask, or a LlamaIndex reader as a route or a few-line function.
  • text/markdown Responses

    embed=markdown returns the page as text/markdown — write it straight into a file, a queue, or a prompt.
  • Generous Free Tier

    Start with 25 requests per day — no account, no credit card. Add an API key when you are ready to scale.

Try it live in the playground

Paste a URL and see the exact markdown output before you write a line of Python.

Python URL to Markdown FAQ

Everything Python developers ask before integrating the Microlink URL to Markdown API.

Do I need Playwright or Selenium?

No. JavaScript rendering runs on Microlink’s managed browser fleet — pass prerender=true and the page is rendered before conversion. Your Python process stays browser-free.

Do I need to install a package?

No. The examples use urllib and json from the Python standard library. If you already use requests or httpx, the same call is one line shorter — see the FastAPI tab above.

How do I convert only the article body?

Pass a CSS selector with data.markdown.selector=article and the extraction is scoped to that element — headers, footers, and sidebars are dropped before conversion, which keeps token counts down.
See the URL to Markdown guide for scoping strategies.

Does it work with LangChain or LlamaIndex?

Yes. The output is a plain markdown string, so it drops into a LangChain Document or a LlamaIndex reader in a few lines — see the framework tabs above.

Is there a free tier or do I need an API key?

The free tier gives you 25 requests per day with no account, no credit card, and no API key. Just call the endpoint and start converting.
When you need more throughput or caching control, add an apiKey header and requests route to the Pro tier. See pricing for the limits.

Can I get the response as markdown instead of JSON?

Yes. Add embed=markdown and the API responds with text/markdown directly — handy for writing files or streaming into prompts without parsing an envelope.

Start converting in Python

Get 25 requests/day with zero commitment — no account and no credit card. Send your first request and ship markdown in minutes.
No login needed
25 reqs/day free
No credit card