Free Online cURL to Code Converter

Paste a curl command below to get the equivalent JavaScript (fetch) or Python (requests) code.

Results are provided for informational purposes only and may contain errors. Please verify important information independently. Use of this tool is at your own risk.

What the cURL to Code does

cURL to Code converts a curl command into the same request written as JavaScript fetch() or Python requests. Paste a command copied from API documentation or from the browser's network panel (Copy as cURL), choose a language and press Convert. The method, URL, headers and request body are carried across.

The parser understands -X/--request, -H/--header, -d/--data/--data-raw/--data-binary and -u/--user. A body without an explicit method turns the request into a POST, as curl does, and -u user:pass becomes an Authorization: Basic header. Line continuations with a backslash are joined first, so multi-line commands paste cleanly. Other flags, such as --compressed or -s, are ignored.

When to use it

  • Turning an example from API documentation into code for a front-end or a Node script.
  • Reproducing a request you captured in browser DevTools inside a Python test.
  • Moving a quick terminal experiment into a scheduled job or a notebook.
  • Explaining to a teammate what a long curl one-liner actually sends.

Worked example

Input

curl -X POST https://api.example.com/users -H "Content-Type: application/json" -d '{"name":"Ana"}'

Output

fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: "{\"name\":\"Ana\"}"
})
  .then(res => res.json())
  .then(data => console.log(data))
  .catch(err => console.error(err));

Common questions about the cURL to Code

Is the request sent when I convert it?

No. The command is only parsed and rewritten as code; the URL in it is never called. Remove real tokens from copied commands anyway, since they end up in your clipboard and your code.

Why is the body a string instead of an object?

curl sends the -d value exactly as written, so the generated code does the same. If you prefer building the body from an object, replace it with JSON.stringify({...}) in JavaScript or json= in Python.

What about file uploads with -F?

Multipart form flags (-F) are not converted. Build those requests with FormData in JavaScript or the files= argument in Python.

Which Python library does the output use?

It uses requests, the most common HTTP library for Python. Install it with pip install requests. The generated script prints the status code and the JSON response.

Is this tool free?

Yes, it's free to use. No signup, no email required. Get results on this page.

How do I get my result?

Use the tool on this page. Your result appears here; no email delivery is required.