Skip to content
Tools

cURL to Python Requests

Turn a cURL command into Python code using the requests library.

Local
Python (requests)

What this tool does

This tool converts a cURL command into Python code that uses the requests library. It reads the method, URL, headers, query parameters and body, and writes a ready-to-run script that sends the request and prints the response.

How the body is handled

A JSON body becomes a Python dictionary passed as json=, so requests sets the content type and serialises it for you. A form body becomes a dictionary passed as data=. A raw body is passed as a string. Multipart fields from -F are split into data= for text fields and files= for file uploads. Query parameters are passed as params= rather than baked into the URL.

Running it

The snippet starts with a uv add requests comment so you can set up the dependency quickly. Add it to a project, run it with your Python runner, and the script prints the status code and the parsed JSON response. Basic auth from -u becomes the auth= tuple that requests expects.

Common use cases

  • Turning a captured request into a Python API test or script.
  • Moving a one-off cURL call into a repeatable, version-controlled form.
  • Learning how a request maps onto the requests API.

Frequently asked questions

Is the request sent?
No. The command is parsed and the Python code is written in your browser. Nothing is sent and nothing is uploaded.
How is the JSON body handled?
As a Python dictionary passed with json=, so requests sets the content type and serialises it for you.

Learning resources

Testsmith also runs hands-on courses and a free practice app for the skills behind this tool.

Feedback welcome

Found a bug in this tool, or want it to do something it does not? Tell us and we will take a look.