Text & Regex

cURL to Code Converter

Convert cURL commands into fetch, Axios, Python requests, and PowerShell code.

Ctrl+Enter to convert
Enter a cURL command to convert.

Your data stays private

This tool runs directly in your browser. The content you enter is processed locally and is not sent to TechFixGen servers. No account or signup is required.

cURL → code conversion, explained

What is cURL → code conversion?

Almost every API page ships example requests as cURL commands. cURL is great at the terminal but awkward to embed in an app. This tool reads the command and rewrites the same request as JavaScript fetch, Axios, Python requests, or PowerShell Invoke-RestMethod so you can paste it straight into your codebase.

# curl
curl -X POST https://api.example.com/v1/users \
  -H "Authorization: Bearer abc123" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Ada", "active": true }'

# fetch
const response = await fetch(
  "https://api.example.com/v1/users",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer abc123",
      "Content-Type": "application/json"
    },
    body: JSON.stringify(
      { "name": "Ada", "active": true }
    )
  }
);

What gets translated

  • URL and query string from the first positional argument that is not a flag or a flag value.
  • Method via -X/--request, with helpful inference:-G means GET, -I means HEAD, and data fields imply POST.
  • Headers from -H/--header, the user agent from -A, the referer from -e, cookies from inline -b values, and Basic auth from -u.
  • Bodies from -d/--data and --json (which also adds the JSON Content-Type and Accept headers), JSON bodies detected and re-indented, and URL-encoded data from --data-urlencode.
  • Multipart from -F/--form, including file fields like name=@file;type=image/png. The per-part type and filename hints are recognized but not carried into the generated code, so set the content type yourself if the API is strict about it.
  • Timeouts from --max-time.

How the targets differ

All four targets start from the same parsed request — one URL, method, header set, and body — and each expresses it in its own idiom: fetch uses an options object with a JSON.stringify body, Axios uses its config object and auth, Python uses headers=/data= with a requests-style call, and PowerShell builds a hashtable for Invoke-RestMethod. Basic auth becomes an Authorization header for fetch, an auth config for Axios, a tuple for Python, and a Base64 Authorization header for PowerShell. The -G rewrite of a body into query parameters is applied before generation, so it appears in every target.

Multipart form data maps to a FormData object in fetch and Axios and a files dictionary in Python. PowerShell can't build multipart without an explicit boundary, so the fields are listed as comments instead of being guessed at.

Limits

  • Shell variables like $TOKEN are kept literal — expand them before pasting.
  • Redirects, cookie jars, SSL options, and repeated downloads are not simulated; the conversion covers a single HTTP request. Using -L is reported in the conversion notes so you know to handle redirects in the client yourself. -c only writes a cookie jar, so there is nothing to translate and you will see a note about it.
  • Unrecognized flags are ignored with a note rather than failing the whole conversion.

Privacy

Conversion runs entirely in your browser. The cURL commands you paste are not uploaded to TechFixGen servers and are not included in analytics events. Working with API requests a lot? The JSON Formatter can clean up the responses next.

Frequently asked questions

Which targets does the converter support?

JavaScript fetch, Axios, Python requests, and PowerShell Invoke-RestMethod. Switch the target dropdown and the generated code updates for the same cURL command.

How is the HTTP method determined?

Precedence runs from -I, then an explicit -X or --request flag, then -G, then inference. So -I always wins, an explicit -X is used as written, -G means GET, and a request with data fields, JSON, or multipart form data is treated as POST. Commands with none of those are GET.

What happens to multipart file uploads?

File fields become placeholder code because a real file can't be sent from the browser: fetch and Axios use a yourFile value to append, Python opens the local path, and PowerShell lists the fields as comments since it needs an explicit boundary. The per-part content type from a type=image/png hint is recognized but not written into the generated code, so set it in the client if the API requires it.

Are shell variables and redirects expanded?

No. Variable references like $TOKEN are kept literal so nothing is guessed, and redirects, cookie jars, and SSL options are not simulated. The result is a single HTTP request to paste into your app. The URL comes from the first bare argument after the flags, not the last, so a command like curl url1 url2 targets url1.

Why are some flags reported as notes?

Unrecognized or unsupported flags are listed in the conversion notes and added as comments in the generated code, so you stay informed without the whole conversion failing on an unusual flag. Notes also cover options that parse correctly but have no generated equivalent, such as -L for redirect following and -c for writing a cookie jar.

Is my cURL command uploaded anywhere?

No. Conversion happens entirely in your browser. The commands you paste are not uploaded to TechFixGen servers and are not included in analytics events.