Skip to content
gohacks.dev
APIs

curl to Code Converter

Paste a curl command, from DevTools or an API's docs, and get the same request as JavaScript fetch, Laravel's Http client, Python requests or Go net/http.

Free · No sign-up · Your inputs stay in your browser

Input

Convert a curl command to code

Output

Result

POST https://api.example.com/v1/orders?expand=items

-H, -d and its variants, --json, -F, -u, -A, -b, -G, -k and -L are translated; output-only flags such as -s, -o and -v are dropped. A command copied from DevTools often carries session cookies and tokens: they stay in this tab, but take them out before pasting the code anywhere else.

Runs in this browser. Nothing you paste is sent to a server.

Copy as cURL

Every browser's DevTools can copy a network request as a curl command, with every header the browser sent. That is the fastest way to reproduce a request outside the browser, and converting it gives working client code. Remove the cookies and tokens it carries before sharing the result.

What changes between languages

curl follows no redirects unless given -L, which the converted code keeps by disabling redirects where the language follows them by default. JSON bodies become native objects in each language: Laravel's Http::post($url, [...]) sends an array as JSON, and Python's requests does it with json=. The flags themselves are documented in the curl manual.

Share

Frequently asked questions

Which curl options are supported?
-X, -H, -d and its variants, --json, --data-urlencode, -F, -u, -A, -b, -e, -G, -k and -L. Output-only flags such as -s, -o, -v and -i are ignored.
Why does the converted request fail when curl works?
Usually a cookie or token that has expired since the command was copied, or a header the language's client sets differently, such as Accept-Encoding.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools