toolbench.online

Turn a browser request into Python or JavaScript

Capture one request as cURL, convert it to requests or fetch, and review credentials and browser restrictions.

Maintained by Toolbench · Updated 10 October 2026

Capture the request you intend to reproduce

Open your browser developer tools, select Network and perform the action once. Select the relevant HTTP request and use Copy as cURL. Check the destination, method and body so you do not accidentally copy a tracking request or a different API call.

The Toolbench converter accepts POSIX shell quoting for one literal request. It supports headers, request methods, basic authentication and literal bodies. Local file references, uploads, shell substitutions and unsupported flags produce errors rather than guessed output.

curl 'https://api.example.com/users' -H 'Content-Type: application/json' --data-raw '{"name":"Alice"}'

Use Python requests for a script

The generated Python code imports requests, supplies the method, URL, headers and UTF-8 body, and uses a 30-second timeout. Install requests in your own environment before running it. The converter itself does not install packages or contact the remote API.

Use response.raise_for_status() before treating an error response as successful data. Print response.text first if you do not know the response format; only use response.json() after checking that the endpoint returns JSON.

import requests
response = requests.request("POST", "https://api.example.com/users",
    headers={"Content-Type": "application/json"},
    data='{"name":"Alice"}'.encode("utf-8"), timeout=30)
response.raise_for_status()
print(response.text)

Choose the Fetch runtime

Browser Fetch is governed by the remote server’s CORS policy. The browser may ignore headers it controls, including Cookie; copying a request from developer tools does not give your script the same privileges as the original page.

Node.js 18+ includes fetch. Run a snippet with top-level await as an ES module. Fetch does not permit GET or HEAD bodies, so the converter rejects that combination. If a request relies on upload files or unusual transport settings, handle it explicitly in code.

const response = await fetch("https://api.example.com/users", {
  method: "POST", headers: {"Content-Type": "application/json"},
  body: JSON.stringify({name: "Alice"})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.text());

Review secrets before sharing

Redact secrets is enabled by default. It masks common authentication headers, cookies, query secrets and named JSON or form-body credentials. Custom field names and credentials embedded in URL paths can require manual review; redaction is a convenience, not a guarantee that a snippet is safe to publish.

Inspect decoded query parameters when a request behaves unexpectedly, and compare response JSON after you run a request in your own environment. Toolbench generates code locally; it cannot validate your session, API permissions or the remote service’s behavior.

Explore the related tool hub