Skip to content
BEAD

cURL Converter

Parse a curl command and emit fetch, Node https, Python requests, Ruby Net::HTTP, Go net/http, PowerShell, HTTPie, and wget equivalents.

POST https://api.example.com/v1/users
2 headers
body: 44 bytes
JavaScript fetch
const res = await fetch("https://api.example.com/v1/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer abc123"
  },
  body: "{\"email\":\"alice@example.com\",\"name\":\"Alice\"}"
});
const data = await res.text();
Node https
import https from "node:https";
const url = new URL("https://api.example.com/v1/users");
const req = https.request({
  method: "POST",
  hostname: url.hostname,
  port: url.port,
  path: url.pathname + url.search,
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer abc123"
  }
}, (res) => {
  let body = "";
  res.on("data", (c) => body += c);
  res.on("end", () => console.log(body));
});
req.write("{\"email\":\"alice@example.com\",\"name\":\"Alice\"}");
req.end();
Python requests
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer abc123",
}
payload = {"email":"alice@example.com","name":"Alice"}
r = requests.post("https://api.example.com/v1/users", headers=headers, json=payload)
print(r.text)
Ruby Net::HTTP
require "net/http"
require "uri"
require "json"

uri = URI("https://api.example.com/v1/users")
req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["Authorization"] = "Bearer abc123"
req.body = "{\"email\":\"alice@example.com\",\"name\":\"Alice\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(req)
end
puts res.body
Go net/http
package main
import (
	"fmt"
	"io"
	"net/http"
	"strings"
)
func main() {
	body := strings.NewReader(`{"email":"alice@example.com","name":"Alice"}`)
	req, _ := http.NewRequest("POST", "https://api.example.com/v1/users", body)
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer abc123")
	res, err := http.DefaultClient.Do(req)
	if err != nil { panic(err) }
	defer res.Body.Close()
	b, _ := io.ReadAll(res.Body)
	fmt.Println(string(b))
}
PowerShell Invoke-WebRequest
$headers = @{
    "Content-Type" = "application/json"
    "Authorization" = "Bearer abc123"
}
$response = Invoke-WebRequest -Method POST -Uri "https://api.example.com/v1/users" -Headers $headers -Body "{\"email\":\"alice@example.com\",\"name\":\"Alice\"}" -MaximumRedirection 0
$response.Content
HTTPie
http POST https://api.example.com/v1/users Content-Type:application/json Authorization:'Bearer abc123' <<< '{"email":"alice@example.com","name":"Alice"}'
wget
wget --method=POST --header='Content-Type: application/json' --header='Authorization: Bearer abc123' --body-data='{"email":"alice@example.com","name":"Alice"}' --max-redirect=0 https://api.example.com/v1/users

What we parse

Method (-X), headers (-H), body (-d, --data-raw, --data-binary), basic auth (-u), cookies (--cookie, -b), insecure flag (-k), follow redirects (-L), and the URL. Quotes (single, double, and $'…') are respected.

Output languages

JavaScript fetch, Node https module, Python requests, Ruby Net::HTTP, Go net/http, PowerShell Invoke-WebRequest, HTTPie, and wget.

You might also like

Used in these workflows