MockFoxAdvertise

cURL converter

Updated Free mock REST & WebSocket APIs

Paste a curl command — for example from Chrome DevTools' “Copy as cURL” or an API's docs — and get equivalent code in JavaScript fetch, Axios, Python requests or Go. Everything runs in your browser.

POST https://mockfox.dev/api/fake/posts2 headersbody 52 chars

const response = await fetch("https://mockfox.dev/api/fake/posts", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    "title": "Hello",
    "body": "From curl",
    "userId": 1
  }),
});

const data = await response.json();

🔒 Converted in your browser — your command, tokens and URLs are never sent anywhere.

How to convert a curl command

  1. Paste the command into the box (multi-line commands with \ continuations are fine) — or copy one from DevTools with Copy as cURL.
  2. Pick the output language. The code updates as you type.
  3. Copy or download the code, and check any warnings about options that can't be converted.

Supported curl options

OptionConverted to
-X, --requestHTTP method
-H, --headerRequest headers (an empty value removes one)
-d, --data, --data-raw, --data-binaryBody; implies POST and form encoding
--data-urlencodeURL-encoded body fields
--jsonJSON body + Content-Type and Accept
-F, --formmultipart/form-data (files and fields)
-u, --userBasic authentication
-b, --cookieCookie header
-A, -eUser-Agent, Referer
-G, --getData moved into the query string
-I, --headHEAD request
-L, -k, --compressedRedirects, TLS verification, compression

Output-only flags such as -s, -v, -i and -o don't change the request and are ignored. Options that read files (-d @file) produce a placeholder and a warning.

Gotchas when translating curl

  • curl doesn't follow redirects unless you pass -L, but fetch, Axios (in browsers), requests and Go do. The converter disables redirects where the library allows it.
  • -d sends application/x-www-form-urlencoded by default, even if the data looks like JSON. Add -H 'Content-Type: application/json' or use --json.
  • Browsers ignore some headers set from JavaScript (Cookie, User-Agent, Host, Referer are forbidden or overridden), and cross-origin calls need CORS.

Need an endpoint to try your code against? Use the free fake REST API or test any HTTP status code.

Related tools

Frequently asked questions

Is my curl command sent to a server?

No. The converter runs entirely in your browser, so API keys, tokens and URLs in your command never leave your device.

How do I copy a request as cURL?

In Chrome, Edge or Firefox DevTools, open the Network tab, right-click a request and choose Copy → Copy as cURL (bash). Paste it here to turn it into code.

Does it support Windows cmd curl commands?

Yes for most commands: ^ line continuations and double-quoted arguments are handled. PowerShell's curl alias (Invoke-WebRequest) uses different syntax and isn't supported.

Which languages can it generate?

JavaScript fetch, Axios (JavaScript/TypeScript), Python with requests, and Go with net/http.

Your business here? Sponsor this tool from $16/week. See placements