cURL Converter

Paste a cURL command from API documentation, a terminal or Chrome DevTools (Copy as cURL) and get the same request as code: Python requests, JavaScript fetch, Axios, Go, PHP or HTTPie. Headers, JSON and form bodies, basic auth, multipart uploads and query data with -G are understood, and options with no equivalent in code are listed instead of silently dropped.

Start from

Copy as cURL from Chrome DevTools (Network tab, right-click a request) works too, bash or Windows style.

Method
POST
URL
https://httpbin.org/post
Content-Type
application/json
Authorization
Bearer YOUR_TOKEN
Body
{"name": "Asha", "city": "Pune", "items": [1, 2]}
Code
Python requests
import requests

headers = {
    'Authorization': 'Bearer YOUR_TOKEN',
}

json_data = {
    'name': 'Asha',
    'city': 'Pune',
    'items': [
        1,
        2,
    ],
}

response = requests.post('https://httpbin.org/post', headers=headers, json=json_data)
print(response.status_code, response.text)

Features

  • Python, fetch, Axios, Go, PHP, HTTPie and cURL output

  • Understands -X, -H, -d, --data-raw, --data-urlencode, --json, -F, -u, -A, -b, -G and -I

  • Bash quoting, $'...' strings and line continuations, plus Windows ^ continuations

  • JSON bodies written as native objects (json= in Python)

  • Notes for options like -k and --compressed

  • Open the converted request in the HTTP client to send it

When to convert cURL

From API docs to code

Payment, SMS and courier APIs document requests as cURL; convert the example into your language.

From the browser to a script

Copy a request as cURL in Chrome DevTools and turn it into a Python or Node script.

Sharing with a teammate

Send a request in the language a colleague works in.

Converting accurately

Things curl does quietly

  • -d without a Content-Type sends a form (application/x-www-form-urlencoded), even if the body looks like JSON. The converter keeps that behaviour and points it out.
  • Several -d options are joined with &.
  • -G moves the data into the URL as a query string.
  • -u user:pass becomes an Authorization: Basic header.

Security

Copied cURL commands often contain live tokens and cookies. Conversion runs in your browser and nothing is sent, but remove secrets before sharing the code.

Related tools

Send the request with the HTTP client; check a response with the JSON formatter.

cURL Converter - FAQ