Ruby URL to Markdown API
Convert any URL to clean, LLM-ready markdown with one HTTP request in Ruby — no headless browser, no readability pipeline, no servers to maintain.
Convert a URL to markdown in Ruby
No gem and no browser — the Microlink REST API turns any URL into clean markdown with a single HTTP GET. Here it is with Net::HTTP and JSON from the Ruby standard library.
Step 01 · Convert any URL
A few lines with the standard library — no gem to add. Point it at a page and read the markdown string from the JSON response.
convert.rb
require 'json'
require 'net/http'
require 'uri'
uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
url: 'https://example.com',
'data.markdown.attr': 'markdown',
meta: false # skip metadata extraction for a faster response
)
res = JSON.parse(Net::HTTP.get(uri))
puts res.dig('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.rb
require 'json'
require 'net/http'
require 'uri'
uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
url: 'https://example.com/blog/post',
'data.markdown.attr': 'markdown',
'data.markdown.selector': 'article', # keep just the article body
meta: false
)
res = JSON.parse(Net::HTTP.get(uri))
puts res.dig('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.rb
require 'json'
require 'net/http'
require 'uri'
uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
'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.parse(Net::HTTP.get(uri))
puts res.dig('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.rb
require 'net/http'
require 'uri'
uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
url: 'https://example.com',
'data.markdown.attr': 'markdown',
meta: false,
embed: 'markdown' # respond with text/markdown instead of JSON
)
File.write('page.md', Net::HTTP.get(uri))Drop it into your framework
A Rails controller, a Sinatra route, or a Sidekiq job — the same request becomes your own URL-to-markdown primitive for agents and RAG pipelines.
- Rails
- Sinatra
- Sidekiq
- Plain Ruby
require 'sinatra'
require 'net/http'
require 'uri'
# GET /markdown?url=https://example.com
get '/markdown' do
uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
url: params[:url],
'data.markdown.attr': 'markdown',
meta: false,
embed: 'markdown'
)
content_type 'text/markdown'
Net::HTTP.get(uri)
endSkip the readability pipeline maintenance
Rolling your own means fetching HTML, running a readability extractor, converting to markdown, and wiring Selenium or Ferrum 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 Selenium, Ferrum or Cuprite plus Chrome
- Each browser eats hundreds of MB of RAM; Puma workers stall
- You build the queueing, retries, caching and autoscaling
- Output quality drifts as sites change; you own the fixes
Microlink for Ruby
- One HTTP request — Net::HTTP from the standard library, no gem to add
- Runs anywhere: Heroku, Rails, 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 Ruby.
A REST API that feels native in Ruby — one call, JSON back, and at home in anything from a Rake task to a Rails 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.
Standard Library Only
Net::HTTP and JSON ship with Ruby — the examples work with zero dependencies and nothing to compile.
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 Rails, Sinatra, or a Sidekiq job as a controller action, route, or worker 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.Standard Library Only
Net::HTTP and JSON ship with Ruby — the examples work with zero dependencies and nothing to compile.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 Rails, Sinatra, or a Sidekiq job as a controller action, route, or worker 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 Ruby.
Ruby URL to Markdown FAQ
Everything Ruby 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 Ruby process stays browser-free.Do I need to install a gem?
No. Net::HTTP and JSON are part of the Ruby standard library, so the examples work with zero dependencies. If you already use faraday or httparty, 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 Heroku or serverless?
Yes. Because there is no browser binary to ship, it works on Heroku, serverless functions, and containers alike — no Chrome buildpack to fight.
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 Ruby
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