Skip to content

PHP URL to Markdown API

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

Convert a URL to markdown in PHP

No package and no browser — the Microlink REST API turns any URL into clean markdown with a single HTTP GET. Here it is with file_get_contents and the cURL extension that ship with PHP.
Step 01 · Convert any URL
A one-liner with file_get_contents — no Composer package to add. Point it at a page and read the markdown string from the JSON response.
convert.php
<?php
$query = http_build_query([
  'url' => 'https://example.com',
  'data.markdown.attr' => 'markdown',
  'meta' => 'false', // skip metadata extraction for a faster response
]);

$res = json_decode(file_get_contents("https://api.microlink.io?$query"), true);

echo $res['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.php
<?php
$query = http_build_query([
  'url' => 'https://example.com/blog/post',
  'data.markdown.attr' => 'markdown',
  'data.markdown.selector' => 'article', // keep just the article body
  'meta' => 'false',
]);

$res = json_decode(file_get_contents("https://api.microlink.io?$query"), true);

echo $res['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.php
<?php
$query = http_build_query([
  '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',
]);

$res = json_decode(file_get_contents("https://api.microlink.io?$query"), true);

echo $res['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.php
<?php
$query = http_build_query([
  'url' => 'https://example.com',
  'data.markdown.attr' => 'markdown',
  'meta' => 'false',
  'embed' => 'markdown', // respond with text/markdown instead of JSON
]);

$markdown = file_get_contents("https://api.microlink.io?$query");

file_put_contents('page.md', $markdown);

Drop it into your framework

A Laravel route, a Symfony controller, or a WordPress shortcode — the same request becomes your own URL-to-markdown primitive for agents and RAG pipelines.
  • Laravel
  • Symfony
  • WordPress
  • Plain PHP
<?php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\HttpClient\HttpClientInterface;

class MarkdownController
{
    // GET /markdown?url=https://example.com
    #[Route('/markdown')]
    public function convert(HttpClientInterface $client): Response
    {
        $res = $client->request('GET', 'https://api.microlink.io', [
            'query' => [
                'url' => $_GET['url'],
                'data.markdown.attr' => 'markdown',
                'meta' => 'false',
                'embed' => 'markdown',
            ],
        ]);

        return new Response(
            $res->getContent(),
            200,
            ['Content-Type' => 'text/markdown']
        );
    }
}

Skip the readability pipeline maintenance

Rolling your own means fetching HTML, running a readability extractor, converting to markdown, and adding a headless browser 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 a readability + markdown converter yourself
  • Every site breaks your selectors in its own special way
  • JavaScript-rendered pages need Panther or a Node sidecar with Playwright
  • 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 PHP

  • One HTTP request — cURL or file_get_contents, no extension to add
  • Runs anywhere: shared hosting, serverless, 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 PHP.

A REST API that feels native in PHP — one call, JSON back, and at home in anything from a script to a Laravel app. Read the URL to Markdown guide to go deeper.

  • No Browser to Install

    No headless browser to install or keep patched. JavaScript rendering runs on Microlink’s side with prerender=true.
  • cURL or file_get_contents

    Use the bundled cURL extension or a one-line file_get_contents — it is a plain HTTP GET, with no Composer package required.
  • 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 Laravel, Symfony, or WordPress as a route, controller, or shortcode in a few lines.
  • text/markdown Responses

    embed=markdown returns the page as text/markdown — pipe 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 headless browser to install or keep patched. JavaScript rendering runs on Microlink’s side with prerender=true.
  • cURL or file_get_contents

    Use the bundled cURL extension or a one-line file_get_contents — it is a plain HTTP GET, with no Composer package required.
  • 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 Laravel, Symfony, or WordPress as a route, controller, or shortcode in a few lines.
  • text/markdown Responses

    embed=markdown returns the page as text/markdown — pipe 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 PHP.

PHP URL to Markdown FAQ

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

Do I need a headless browser?

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

Do I need to install a Composer package?

No. The examples use file_get_contents and the cURL extension that ship with PHP. If you already use Guzzle or Laravel’s HTTP client, the same request translates directly.

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 run on shared hosting or serverless?

Yes. Because there is no browser binary to ship, it works on shared hosting, serverless functions, and containers alike — a plain HTTPS call with nothing to compile.

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 piping into files, queues, or prompts without parsing an envelope.

Start converting in PHP

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