Convert cURL to a .http file (and back)

API docs, browser DevTools and colleagues hand you requests as cURL commands. A .http file is easier to keep: one request per block, headers on their own lines, variables instead of pasted tokens, and it can be sent with one click from VS Code. This page shows both directions and the .http equivalent of each common cURL flag.

Online converters: cURL to .http and .http to cURL (and 10 other languages). Both run in your browser; nothing is uploaded.

The quick way with Plainwire

  1. Copy the cURL command. From browser DevTools, use Copy as cURL (bash); the Windows cmd variant uses ^ escapes that are harder to read.
  2. Run Plainwire: Import cURL Command… and paste the command (it is pre-filled when a cURL command is on your clipboard). You can also paste a cURL command straight into the URL box of a request tab.
  3. Plainwire turns it into a request you can save in a .http file. Replace any pasted tokens with a {{variable}} before committing.

For the other direction, use Plainwire’s copy as cURL on any request to put a cURL command on the clipboard, ready for a terminal, a bug report or a CI script.

A full example

This command:

curl -X POST 'https://api.example.com/v1/orders?notify=true' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer eyJhbGciOi...' \
  -H 'X-Request-Id: 7f3c' \
  -d '{"sku":"TSHIRT-M","quantity":2}'

is this request:

### Create order
POST https://api.example.com/v1/orders?notify=true
Content-Type: application/json
Authorization: Bearer {{token}}
X-Request-Id: {{$guid}}

{"sku":"TSHIRT-M","quantity":2}

The token moved to an environment variable ({{token}}, defined in http-client.private.env.json), and the hand-typed request id became a fresh {{$guid}} on every send.

Flag-by-flag mapping

Use this table to convert by hand or to check a conversion.

cURL.http equivalent
curl URLGET URL
-X, --request PUTMethod on the request line: PUT URL
-H, --header 'Name: value'A Name: value line
-d, --data, --data-raw 'body'Body after a blank line; method becomes POST unless -X says otherwise; add Content-Type: application/x-www-form-urlencoded if no type was given (cURL’s default)
--json '{...}'POST, Content-Type: application/json, Accept: application/json, and the JSON body
--data-binary @file.jsonBody line < ./file.json
--data-urlencode 'q=hello world'Form body with the value encoded: q=hello%20world
-G with -d 'a=1'Query string instead of body: GET URL?a=1
-u, --user user:passAuthorization: Basic + base64 of user:pass
--oauth2-bearer TOKENAuthorization: Bearer TOKEN
-A, --user-agent 'x'User-Agent: x
-e, --referer URLReferer: URL
-b, --cookie 'a=1; b=2'Cookie: a=1; b=2
-I, --headHEAD URL
-F, --formA multipart/form-data body with a boundary; check multipart requests carefully after converting
-L, -k, --compressed, -s, -v, -o, --max-timeClient behaviour rather than part of the request; no line in the file

-k (skip TLS verification) has no Plainwire equivalent yet; see support for self-signed certificates.

More examples

Basic auth and a query built with -G

curl -G https://api.example.com/search \
  -u ada:s3cret \
  --data-urlencode 'q=red shirts' \
  -d limit=20
GET https://api.example.com/search?q=red%20shirts&limit=20
Authorization: Basic YWRhOnMzY3JldA==

YWRhOnMzY3JldA== is base64 for ada:s3cret. In a shared file, keep the password in an environment instead.

Form post

curl https://api.example.com/login \
  -d 'username=ada' -d 'password=s3cret'
POST https://api.example.com/login
Content-Type: application/x-www-form-urlencoded

username=ada&password={{password}}

cURL joins several -d values with &, which is why both fields end up in one body.

Body from a file

curl -X PUT https://api.example.com/config \
  -H 'Content-Type: application/json' \
  --data-binary @config.json
PUT https://api.example.com/config
Content-Type: application/json

< ./config.json

The path is relative to the .http file. Plain -d @file strips newlines from the file before sending, while --data-binary and < send it unchanged.

Cookies and a custom user agent

curl https://shop.example.com/cart \
  -b 'session=abc123; theme=dark' \
  -A 'my-script/1.0'
GET https://shop.example.com/cart
Cookie: session={{session}}; theme=dark
User-Agent: my-script/1.0

From .http back to cURL

Going the other way, variables are resolved first using the selected environment, then each part becomes a flag. This request:

@baseUrl = https://api.example.com

### Update user
PATCH {{baseUrl}}/users/42
Content-Type: application/json
Authorization: Bearer {{token}}

{"name":"Ada"}

becomes a command like:

curl -X PATCH 'https://api.example.com/users/42' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <value of token>' \
  --data-raw '{"name":"Ada"}'

Because the result contains resolved secrets, check it before pasting it into a public issue or chat.

Why convert at all?

Related: .http syntax cheat sheet, Postman to .http.