Skip to main content

Confirm

Are you sure?

cURL · Code recipe

Get the rendered HTML of a JavaScript page in cURL

Fetch the HTML a browser ends up with, JavaScript and all, in any shell with curl with curl. Every program on this page runs as it stands — each one was run against a stub of the API before it was published.

By · Last updated: September 2026

TL;DR

To get the HTML of a JavaScript-rendered page in cURL, POST its URL to https://urlpipe.dev/html with sync set to true. The body is the DOM after the page's scripts ran in real Chrome, serialized as HTML — what a visitor's browser holds, not what the server first sent — read with curl -o, for 1 credit.

Free plan, no credit card. 1,000 credits a month.

One POST to /html loads the page in real Chrome, lets its JavaScript run, and serializes the DOM it ended up with. For a single-page app that is the difference between an empty <div id="root"> and the content; the rendered vs raw HTML guide shows how far apart the two get.

The body is the HTML as text, read with curl -o. The program saves it and reports its size in bytes — compare that with curl -s https://example.com | wc -c and you see how much of the page only exists after the scripts ran.

Setup

Before you start

curl is on every Mac and almost every Linux box. jq reads the token in the async script; install it from your package manager if jq --version finds nothing.

Terminal
curl --version | head -1
jq --version        # brew install jq / apt install jq
export URLPIPE_API_KEY="your_api_key"

The request

Save the rendered HTML and report its size

"sync": true keeps the request open until the result is ready. -w '%{http_code}' hands you the status and -o parks the body in a file, so an error message is printed, not decoded or saved as if it were the result. --max-time stops a page that never finishes loading from hanging the script. wc -c counts bytes, the size you want.

rendered_html.sh
#!/usr/bin/env bash
set -euo pipefail

response=$(mktemp)
trap 'rm -f "$response"' EXIT

# -w prints the status; -o keeps the body out of the way until the status is known.
status=$(curl -sS --max-time 90 -o "$response" -w '%{http_code}' \
  https://urlpipe.dev/html \
  -H "Authorization: Bearer $URLPIPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "sync": true}')

if [ "$status" != 200 ]; then
  echo "URLpipe answered $status: $(cat "$response")" >&2
  exit 1
fi

cp "$response" page.html
echo "Saved page.html ($(wc -c < page.html | tr -d ' ') bytes)"

Run it: bash rendered_html.sh

Async

The async variant: a token, a webhook and a poll

Leave out sync and the answer is a token, straight away; jq -r .token pulls it out without quotes. The loop polls every two seconds and the case covers the four answers GET /result/:token can give.

rendered_html_async.sh
#!/usr/bin/env bash
set -euo pipefail

response=$(mktemp)
trap 'rm -f "$response"' EXIT

API=https://urlpipe.dev
AUTH="Authorization: Bearer $URLPIPE_API_KEY"

# No "sync": the request is accepted at once and the work carries on without you.
status=$(curl -sS -o "$response" -w '%{http_code}' "$API/html" \
  -H "$AUTH" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "report_to": "https://your-app.com/webhooks/urlpipe",
    "labels": {"customer": "acme"}
  }')
if [ "$status" != 200 ]; then
  echo "URLpipe answered $status: $(cat "$response")" >&2
  exit 1
fi
token=$(jq -r .token "$response")
echo "Accepted $token"

# The result is POSTed to report_to when it is ready. Polling by token is the
# other way to collect it: no endpoint needed, and a backup for the webhook.
for _ in $(seq 60); do
  status=$(curl -sS -o "$response" -w '%{http_code}' "$API/result/$token" -H "$AUTH")
  [ "$status" = 202 ] || break # 202 means still processing
  sleep 2
done

case "$status" in
  200) ;;
  202) echo "Still processing after two minutes; try the token again later." >&2; exit 1 ;;
  422) echo "The analysis failed: $(jq -r .error "$response")" >&2; exit 1 ;;
  410) echo "The result is past the 30-day window; send the request again." >&2; exit 1 ;;
  *) echo "URLpipe answered $status: $(cat "$response")" >&2; exit 1 ;;
esac

cp "$response" page.html
echo "Saved page.html ($(wc -c < page.html | tr -d ' ') bytes)"

Run it: bash rendered_html_async.sh

Errors

Handle errors and retries

-D writes the response headers to a file, which is where Retry-After is read from. A 401 answers in plain text, so it is decided on the status alone; jq reads the error code of everything else.

rendered_html_errors.sh
#!/usr/bin/env bash
set -euo pipefail

response=$(mktemp)
headers=$(mktemp)
trap 'rm -f "$response" "$headers"' EXIT

# urlpipe PATH JSON: POST a sync request, leaving the result in $response.
# Retries the two 429s that clear by themselves; fails with a message otherwise.
urlpipe() {
  local attempt status code detail retry_after
  for attempt in 0 1 2 3 4; do
    status=$(curl -sS --max-time 90 -o "$response" -D "$headers" -w '%{http_code}' \
      "https://urlpipe.dev$1" \
      -H "Authorization: Bearer $URLPIPE_API_KEY" \
      -H "Content-Type: application/json" \
      -d "$2")
    case "$status" in
      200) return 0 ;;
      401) echo "URLpipe: 401: the API key is missing or wrong. Check URLPIPE_API_KEY." >&2; return 1 ;;
    esac

    # A body that is not JSON leaves both empty.
    code=$(jq -r '.error // ""' "$response" 2>/dev/null || true)
    detail=$(jq -r 'if .message then "\(.error): \(.message)" else .error end' "$response" 2>/dev/null || true)

    if [ "$status" = 429 ] && [ "$code" = rate_limited ]; then
      # Sending too fast: Retry-After says how long the window has left.
      retry_after=$(awk 'tolower($1) == "retry-after:" { print $2 + 0 }' "$headers")
      sleep "${retry_after:-1}"
    elif [ "$status" = 429 ] && [ "$code" = concurrency_limit ]; then
      # Every parallel slot on your plan is busy with your own requests.
      sleep $((2 ** attempt))
    elif [ "$status" = 504 ]; then
      # Still running on our side; the token collects it from GET /result/:token.
      echo "URLpipe: 504 processing_timeout: collect it later with token $(jq -r .token "$response")" >&2
      return 1
    else
      # 403 email_unverified, 422 (a bad parameter, or a page that would not load),
      # 429 quota_exceeded: sending the same request again gets the same answer.
      echo "URLpipe: $status: $detail" >&2
      return 1
    fi
  done
  echo "URLpipe: 429: still refused after 5 attempts" >&2
  return 1
}

urlpipe /html '{"url": "https://example.com", "sync": true}' || exit 1

cp "$response" page.html
echo "Saved page.html ($(wc -c < page.html | tr -d ' ') bytes)"

Run it: bash rendered_html_errors.sh

Details

What to know about /html

  • The HTML is serialized from the live DOM, so it is well-formed but not byte-identical to any file on the server.
  • Pages over 10 MB of HTML are refused with The page is too big to be processed.
  • page_options.wait_for_selector waits for an element that loads late; delay waits a fixed time on top.
  • It is the whole document, scripts and styles included, not a cleaned-up version of it. For clean text, use Markdown instead.

Other languages

Get the rendered HTML of a JavaScript page in another language

More cURL: every cURL recipe

FAQ

Frequently asked questions

How is this different from fetching the URL myself?
A plain GET returns what the server sent before any JavaScript ran. /html returns the DOM after the page's scripts ran in real Chrome — the HTML a visitor's browser actually holds.
Can I wait for content that loads late?
Yes: page_options.wait_for_selector waits up to 10 seconds for an element to appear, and delay adds a fixed wait. If the element never appears the request is a 422 and costs nothing.
Does URLpipe follow robots.txt?
Yes, by default, for every project. You can turn it off per project, and then you are responsible for having the right to fetch those pages.
Do I need an SDK to call URLpipe from cURL?
Nothing beyond curl and jq, which most machines already have.

Get a key and run it.

Free plan, no card. Paste your key into URLPIPE_API_KEY and every program on this page runs as it is.