Get clean Markdown from a URL, without navigation or boilerplate
Clean Markdown from a URL starts with converting the right element, not with cleaning up afterwards. Whole-page Markdown carries the menu, the footer, the cookie notice and three related-post widgets, and every one of them costs tokens and confuses retrieval. The Markdown API lets a RAG pipeline, a read-it-later app or a docs importer convert exactly the element that holds the content, so only the article body turns into Markdown.
Navigation and boilerplate end up in your Markdown
On a typical article page the readable text is a minority of the markup. Navigation, sidebars, comment forms and legal footers repeat on every URL of the site, so an index built from whole pages is dominated by identical noise. Ask it a question and the closest match is often a menu.
Cleaning after the conversion means heuristics: a readability API or library, regular expressions over Markdown, per-site blocklists of phrases. They work until a layout changes, and they fail silently, either by leaving the newsletter form in or by cutting the last paragraph of the article out.
Microlink’s conversion already drops scripts, styles and navigation chrome, and adblock removes third-party ads, trackers and consent services at the network level before the page renders. For everything else, a selector scopes the conversion to main or article, and a small injected script removes site-specific widgets inside that scope before the conversion runs.
How to get clean Markdown from a URL with a selector
A selector does most of the work. selectorAll returns one Markdown string per match when the content is a list, and modules removes leftovers inside the scope. The URL to Markdown guide shows the same scoping with the raw API.
import createClient from 'microlink.io'
const microlink = createClient({
apiKey: process.env.MICROLINK_API_KEY
})
const markdown = await microlink.markdown('https://example.com/blog/post', {
selector: 'article'
})The conversion is limited to the first element matching the selector, so the header, the sidebar and the footer never enter the Markdown. The call resolves to a string.
import createClient from 'microlink.io'
const microlink = createClient({
apiKey: process.env.MICROLINK_API_KEY
})
const comments = await microlink.markdown('https://example.com/thread', {
selectorAll: '.comment'
})
console.log(comments.length)selectorAll resolves to an array with one Markdown string per matching element, which suits threads, listings and search results where each item should become its own document.
curl 'https://api.microlink.io/?url=https%3A%2F%2Fexample.com%2Fblog%2Fpost&data.markdown.selector=main&data.markdown.attr=markdown&meta=false&embed=markdown&modules=document.querySelectorAll%28%27.share%2C+.newsletter%2C+.related%27%29.forEach%28node+%3D%3E+node.remove%28%29%29'modules runs JavaScript in the page before the conversion, so the removed nodes never reach the Markdown, and embed=markdown returns the result directly as text/markdown. The page preparation guide covers click, scroll and styles for pages that need more.
- selector Scope the conversion to the first element matching a CSS selector.
- selectorAll Convert every matching element and get an array with one Markdown string each.
- adblock Blocks third-party ad, tracker and cookie consent requests. On by default.
- modules Inject inline JavaScript or a module URL to remove site-specific widgets before the conversion runs.
- meta false skips metadata detection when you only want the body. Default true.
Start with main or article, since most publishing platforms wrap the content in one of them, and fall back to a site-specific selector only when they do not. Paste a URL into the URL to Markdown tool to see the unscoped output you are starting from.
Why scoping at the source gives cleaner Markdown
Cleaning Markdown after the fact needs heuristics. Scoping the conversion needs a selector.
The Markdown API page puts the saving at up to 80% fewer tokens than raw HTML, and scoping compounds it.
For a whole site, run the scoped request over every URL with bulk Markdown conversion, and convert list items with selectorAll so each item becomes its own document.
When not to: if you convert thousands of unrelated sites and cannot maintain selectors, start with main and article and accept some noise. A per-site selector map is a later optimization, not a prerequisite.
FAQ
Which selector gives the cleanest Markdown for an article?
What happens if the Markdown selector matches nothing?
How do I get clean Markdown from a URL without the navigation?
Does adblock change the Markdown output?
Can I remove elements inside the scoped Markdown content?
Solve the next problem with the same API
Markdown with metadata frontmatter
Markdown from JavaScript-rendered pages
LLM context from any URL
Bulk Markdown conversion with caching
Clean PDFs without ads or banners
Screenshots without cookie banners or ads
Ready for content-only Markdown?
One selector removes the noise at the source. Start on the free tier and convert your first article body today.