cURL to Python Converter

Paste one curl command from your terminal, a manual or a browser's copy menu. You get Python code that makes the same request with the requests library, and a list of what each option became.

Free Runs in your browser Checked Tuesday, November 10, 2026

One command. Quotes and line breaks written with a backslash are read the way a shell reads them. Do not paste a live password or token you want to keep private.

Result

Python code — Copy it into a script. It needs the requests library installed.
Python code
JavaScript fetch code

What the translation did

This tool runs in your browser. What you enter is not sent to us.

How to use it

  1. Paste one curl command into curl command. Keep the quotes around values that contain spaces.
  2. Read What the translation did to check each option: the method, the query string, the body and the headers.
  3. Copy the Python code into your script, with the requests library installed, or the JavaScript fetch code into a page.
  4. If a note or an error appears, fix the command first, then copy the code again.

Which curl options the tool reads

The tool reads the options most requests use. Each one changes the Python call in a known way, and any other option stops the translation with a message, so nothing is guessed.

  • -X and --request set the method, as written. The manual says it only changes the word sent.
  • -H and --header add headers. A line such as X-Flag; sends an empty value, and -H with an empty value after the colon removes a header.
  • -d, --data, --data-raw and --data-binary set the body. Several -d values are joined with &. With -G they become the query string instead.
  • -G and --get, -I and --head, and -L and --location change the method or the redirect handling.
  • -u and --user, -A and --user-agent, and -b and --cookie set the auth tuple, the User-Agent header and the Cookie header.
  • --json sends the value as the body and sets the JSON headers, which -H can override.

How the command is read

The text is split into words the way a POSIX shell splits them. Single quotes keep every character. Inside double quotes a backslash only escapes the characters $, backquote, double quote, backslash and newline. A backslash at the end of a line joins it to the next line. Shell expansions such as $HOME are not run, so such values are reported as errors.

What the tool does not check

  • It does not send the request, so it cannot tell you whether the server accepts it.
  • A browser applies its cross-origin rules to fetch. A request to another site can be blocked there, even when the same command works in a terminal. The tool does not test that.
  • It does not open files named with @, and it does not read cookie files.
  • It writes Python only. The code uses the requests library, which you install separately.

Worked example: a PUT with a JSON body

The command sends a PUT to one item with a JSON body. The method comes from -X, the header from -H and the body from -d. The Python call has the same three parts, and the steps list says which option gave which value.

curl option Python argument Value in the code
-X PUT method 'PUT'
-H 'Content-Type: application/json' headers 'Content-Type': 'application/json'
-d '{"name": "Ada"}' data '{"name": "Ada"}'

Frequently asked questions

Why does the code use requests and not another library?

requests is the Python library the tool translates to, and its request function takes a method, a URL, headers, data and auth in one call. The same call works for every method that the command names.

Why is my request sent as POST when I did not write -X?

The curl manual says -d uses POST, and --json sends a POST too. Write -X with the method you want, such as -X PUT, to change the word sent.

What does -G do in the translation?

It moves the -d data into the URL as a query string and makes the request a GET, as the manual describes. The Python call then has the full URL and no body.

Are the passwords in my command sent anywhere?

No. The command is read in your browser, and nothing is stored or sent to us. Still, use a test password or token on a page you do not control.

Why does the output mention redirects?

curl follows redirects only with -L. requests follows them by default for every method, and fetch does too, so the note tells you how to match a curl call that has no -L.

Can the tool read data from a file named with @?

No. The tool does not open files, so an @ value is reported as an error. Paste the data itself into the command.

Sources

Figures and text last checked on Tuesday, November 10, 2026.

We use necessary cookies to run the site. With your consent, Google also uses advertising cookies to show personalised ads. If you reject them, you still see ads, but they are not personalised.