Advertisement
Guide
About the cURL to Code
Browsers, API docs and tools like Postman all speak curl: in DevTools you can right-click any request and choose Copy as cURL. This tool reads that command — quotes, $'…' escapes, Windows ^ escapes and line continuations included — and writes the same request in the language you are working in.
The generated code was checked by running it: the original curl and the generated Python, JavaScript and PowerShell sent identical requests to a test server — same method, path, headers, cookies, auth and body — including with secrets read from environment variables.
Clean up what the browser copied
A request copied from DevTools carries a dozen headers the browser added on its own — sec-ch-ua, sec-fetch-mode, accept-language and friends. They are dropped by default so the code shows only what the server needs. If an API checks one of them, untick the option.
Keep credentials out of the code
Copied requests usually contain your session cookie or an access token. Choose Environment variables and every token, cookie, API key and secret query parameter is read from the environment instead — os.environ, process.env, os.Getenv and so on — with a .env file to copy. Secret query values are URL-encoded where they are joined into a URL. Or choose Redact to replace them with REDACTED for sharing.
Convert any request from a HAR file
In DevTools, open the Network tab, reproduce what you need and choose Save all as HAR. Open the file here to list every request — filtered to API calls by default — and convert the one you pick. Headers the client computes itself, such as Content-Length and HTTP/2 pseudo-headers, are left out.
How to use it
- 1Copy a request as cURL or fetch from DevTools — or save the Network tab as a HAR file.
- 2Paste it, or open the HAR file and pick a request.
- 3Switch off headers or parameters you do not need, and choose how to handle secrets.
- 4Pick a language, then copy or download the code.
Frequently asked questions
Which curl options are supported?
The ones that change the request: -X, -H, -d / --data-raw / --data-binary / --data-urlencode, --json, -F, -u, -b, -A, -e, -G, -I, -T, -k, -L, -m, -x and --oauth2-bearer, with short flags combined (-sSL) or attached (-XPOST). Output-only options such as -o, -s, -v and --compressed are accepted and ignored.
Does it handle "Copy as cURL (cmd)" from Chrome on Windows?
Yes. The cmd version escapes characters with ^ and uses double quotes; it is detected automatically, as are the bash version's $'…' strings.
Can I convert fetch to curl?
Yes. Paste a fetch("url", { … }) call, such as DevTools' "Copy as fetch", and choose the curl output.
Why does the Python code use json= instead of data=?
When the body is JSON, requests' json= argument serialises it and sets the Content-Type for you, which is the idiomatic form. Form bodies use data= and files use files=.
What about files sent with -F [email protected] or -d @body.json?
They are kept as file reads in the generated code, using the path from the command. In browser fetch and axios the file comes from a file input instead.
Can I import the request into Postman or an editor?
Yes. Choose Postman to get a collection file (v2.1) to import, or .http file for the VS Code REST Client and the JetBrains HTTP Client. With environment variables on, secrets become {{API_TOKEN}}-style variables: empty in the Postman collection, and read from your .env file in the .http file.
Can I convert several requests at once?
Paste several curl commands (DevTools "Copy all as cURL") or fetch() calls, or open a HAR file, and pick each request from the list.
How are secrets turned into environment variables?
Authorization tokens become API_TOKEN, cookies COOKIE, keys like X-Api-Key X_API_KEY and secret query parameters such as access_token ACCESS_TOKEN. The code reads them from the environment, and a matching .env file can be copied.
Is my command sent anywhere?
No. Parsing and code generation run in your browser, and what you paste or open is not saved or included in share links because it usually contains cookies or tokens.
