Home
DT

Convert cURL commands to code

Turn any cURL command into fetch, Axios, Python requests or Go.

This tool runs entirely in your browser. Nothing you type is sent to a server.

Moving a cURL command from API documentation or your browser's network tab into application code is mechanical work with a high error rate. Drop one header or mangle one layer of quoting and you get a 401 or a 400, then spend twenty minutes finding out why.

This converter parses the command into method, URL, headers, cookies, body and auth, then emits equivalent code for JavaScript fetch, Axios, Python requests, Go net/http and PHP cURL. Line continuations, mixed quoting, repeated --data flags and -G (send the body as a query string) are all handled.

How to use

  1. Paste the cURL commandDrop it into the left pane — including anything you got from Chrome DevTools via Copy as cURL. A bare URL with no curl prefix is treated as a GET request.
  2. Check what was parsedThe method and URL appear as badges below the input, and the table at the bottom lists every header, cookie and body field that was recognised. If something is missing, check the quoting in the original command.
  3. Choose a target languageSwitch between fetch, Axios, Python, Go and PHP. JSON bodies are expanded into real object or dictionary literals, and the Python output converts true and null to True and None.
  4. Copy, then clean up secretsThe generated code runs as-is, which means any tokens and cookies from the original command are inlined. Move them to environment variables before committing.

Frequently asked questions

Can I paste Chrome's 'Copy as cURL' output directly?

Yes — that is the main use case this was built for.

Be aware that the browser includes every header it sent: sec-ch-ua, sec-fetch-mode, user-agent and your full session cookie. None of those belong in server-to-server code, and keeping them produces something that pretends to be a browser. After converting, keep the auth header and Content-Type and delete the rest. On Windows, choosing Copy as cURL (bash) parses more reliably.

Does it convert file uploads (`-F`)?

Yes. A value beginning with @, such as -F 'file=@/path/to/a.png', is recognised as a file.

The fetch and Axios output builds a FormData and appends the fields, but browsers cannot read a local path, so you must substitute a real File object — typically from an <input type="file">. The Python output uses open(path, "rb") and works unchanged.

The generated code contains my auth token.

It carries over exactly what was in your command. The conversion happens in your browser, so nothing was transmitted.

But committing that code writes the token into your repository history permanently. Replace it with process.env.API_TOKEN or os.environ["API_TOKEN"] first. If it is already committed, editing the file is not enough — revoke and reissue the token.

Concepts worth knowing

What the cURL flags mean

-X sets the HTTP method, -H adds a header, -d/--data supplies a body, -F sends multipart form data, -u does Basic auth and -b sends cookies. -L follows redirects and -k skips TLS verification.

Using -d implies POST even without -X, and defaults the content type to application/x-www-form-urlencoded. Forgetting to set Content-Type: application/json when sending JSON is one of the most common causes of a server silently failing to parse the body.

fetch versus Axios in practice

fetch ships with browsers and modern Node, so there is no dependency to add. In exchange, it does not reject on HTTP error statuses — you must check response.ok yourself — and you serialise JSON bodies manually.

Axios throws on 4xx and 5xx, serialises objects and sets Content-Type for you, and makes it easy to centralise token refresh in an interceptor. For a handful of calls, fetch is plenty; for a client with a lot of shared behaviour, Axios removes boilerplate.

data versus json in requests

In Python's requests, passing a dict to data= form-encodes it, while json= serialises to JSON and sets the application/json content type automatically.

This tool emits json=payload whenever the body parses as valid JSON. Use data= only when you genuinely need to send a raw string. Note that requests is not in the standard library (pip install requests), and httpx offers a nearly identical API with async support if you need it.

Related tools

Last updated: 2026-08-12