cURL Command Builder

Build a curl command from a method, URL, headers, auth and body, or paste one to edit it. Get it quoted for bash, cmd or PowerShell, or converted to fetch, Axios or Python.

Import a curl command

Tip: paste a whole curl command here to import it.

Query params

Headers

Auth

Body

Options

Command

Why build curl commands instead of typing them?

curl is the shared language of HTTP: API docs print their examples in it, bug reports paste it, and browser DevTools copy requests as it. Typing one by hand is where mistakes creep in, like a header with a stray quote, a JSON body the shell splits in two, or an unencoded space in a query string. The builder assembles the command from structured fields, percent-encodes query parameters and quotes every argument for the shell you pick. It also works the other way: paste a curl command to edit it, run it on Windows, or turn it into fetch, Axios or Python code. It all happens in your browser, so tokens you type never leave the page.

How it works

  1. Start from scratch with a method and URL, or paste an existing curl command into Import (or straight into the URL box) to fill in the form.
  2. Add query parameters and headers as rows, then pick an auth type: a Bearer token, Basic auth (sent with -u), or an API key in a header or the query string.
  3. Pick a body type: JSON, raw text, urlencoded form, multipart form or GraphQL. A matching Content-Type is added unless you set your own.
  4. Choose the output: curl for bash, cmd or PowerShell, or the same request as JavaScript fetch, Axios or Python requests. Copy it, or download it as a .sh, .bat, .ps1, .js or .py file.

Anatomy of a curl command

Every command the builder writes has the same shape: the program, the method, the quoted URL, then the body and header options. Here is a POST with one query parameter, an Accept header, a Bearer token, and a JSON body, exactly as the tool outputs it for bash:

curl \
  -X POST \
  'https://api.example.com/users?notify=true' \
  --data-raw '{"name":"Ada","role":"admin"}' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json'
  • The URL sits in quotes. Without them, the & between query parameters would tell the shell to run the command in the background and cut the URL short.
  • --data-raw carries the body exactly as written.
  • The Authorization and Content-Type headers come from the Auth and Body settings, not the header rows.

curl doesn't care about option order, so you can rearrange lines freely. The backslash at the end of each line only tells the shell that the command continues.

Convert curl to Python, fetch or Axios

API documentation usually shows curl, but your program needs code. Import the command, pick an output tab, and the builder writes the same request, method, headers, auth and body included. This curl command:

curl \
  -X POST \
  'https://api.example.com/users' \
  --data-raw '{"name":"Ada","role":"admin"}' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json'

becomes this with Python's requests library:

import requests

url = "https://api.example.com/users"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
}
payload = {
    "name": "Ada",
    "role": "admin",
}

response = requests.post(url, headers=headers, json=payload)
print(response.status_code, response.text)

and this with fetch, which is built into browsers and Node.js 18 and later:

const response = await fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "Ada",
    "role": "admin"
  }),
});

console.log(response.status, await response.text());

A few behaviours differ between curl and these libraries, and the output notes point them out when they apply:

  • Redirects. curl stays on a 301 or 302 unless you pass -L; fetch, Axios and requests follow redirects by default.
  • Content-Type. curl labels any -d body as a form unless told otherwise, so a JSON body sent without a header is often rejected. requests' json= and Axios set the JSON type for you.
  • Certificate checks. -k becomes verify=False in requests and an https.Agent option in Axios on Node; fetch has no equivalent.
  • Files. -F file=@photo.png becomes open("photo.png", "rb") in Python and a FormData entry in JavaScript.

Import a request from your browser

To reproduce exactly what a web page sends, open DevTools (F12), switch to the Network tab, reload, right-click the request and chooseCopy › Copy as cURL (Chrome and Edge) or Copy Value › Copy as cURL (Firefox). Paste it into the import box. Commands copied for bash and for Windows cmd are both understood, including ANSI-C $'…' strings and ^ escapes. Options that only change curl's output, like -s,-o or -w, are dropped with a note, and anything the builder can't represent, such as a proxy, is listed rather than silently lost. Copied requests carry your cookies and session tokens: delete those headers before you share the command with anyone. To inspect a JWT from an Authorization header, paste it into the JWT decoder; to tidy a JSON response, use the JSON formatter; and to encode a single value by hand, theURL encoder and Base64 encoder do the same encoding the builder applies.

Common curl flags

These flags cover most day-to-day API work. The last column shows which builder setting writes each one.

FlagWhat it doesIn the builder
-X, --requestSets the HTTP method.Method menu (every method except HEAD)
-I, --headSends a HEAD request and prints only the response headers.Method menu: HEAD
-H, --headerAdds one request header, written Name: value.Headers, Bearer token, API key
-d, --dataSends a body and implies POST. A value starting with @ is read from a file.Not used (see --data-raw)
--data-rawLike -d, but a leading @ is sent as text.JSON, raw text, GraphQL
--data-urlencodePercent-encodes the value of one name=value pair.Form (urlencoded)
-F, --formAdds a multipart field; @path attaches a file.Form (multipart), rows marked File
--form-stringAdds a multipart text field; a leading @ or < is sent as text.Form (multipart), text rows
-u, --userBasic auth as user:password.Basic auth
-L, --locationFollows redirects.Follow redirects
-k, --insecureSkips TLS certificate checks. For local testing only.Insecure
--compressedAsks for a compressed response and decodes it.Compressed
-g, --globoffSends a URL containing { } or [ ] as written instead of expanding it as a pattern of several URLs.Added automatically when the URL needs it
-i, --includePrints the response headers above the body.Add by hand
-v, --verboseShows the full exchange, including the request headers curl sent.Add by hand

Quoting rules in bash, cmd, and PowerShell

Most broken curl commands aren't curl problems. The shell rewrites the arguments before curl ever sees them, and each shell has its own rules.

bash and zsh (macOS, Linux, WSL, Git Bash)

Single quotes make everything literal: dollar signs, exclamation marks, ampersands, and spaces pass through untouched. The one character a single-quoted string can't hold is a single quote, so the builder closes the quote, adds an escaped one, and reopens it. A line continues with a backslash, which must be the very last character on the line; a stray space after it ends the command early.

Windows Command Prompt (cmd.exe)

cmd has no single quotes; it passes them through as ordinary characters, which is why commands copied from Linux docs often fail on Windows. The builder wraps each argument in double quotes, writes inner quotes as \" (curl turns them back into quote marks), and continues lines with a caret (^). cmd itself doesn't understand \", so after one it believes the quotes have closed; wherever cmd would then see &, |,<, >, or ^ outside quotes, the builder puts a caret in front so it stays part of the text. In a .bat file, % marks a variable, so the downloaded request.bat writes an encoded %20 as %%20; at an interactive prompt a single% is left alone unless it happens to spell out the name of an existing variable. cmd also can't carry a line break inside an argument, so line breaks in a JSON body become spaces, which JSON ignores.

PowerShell

Single quotes are literal here too, and a single quote inside one is doubled; PowerShell also treats curly ‘smart’ quotes as quote marks, so those are doubled as well. Lines continue with a backtick. In Windows PowerShell 5.1, the version built into Windows 10 and 11,curl is an alias for Invoke-WebRequest, so the builder always callscurl.exe, the real program. PowerShell releases before 7.3 also strip plain double quotes from an argument passed to a native program, which mangles JSON bodies, while 7.3 and later pass them intact. So when an argument contains a double quote, the builder writes it as \" and wraps the command in& { $PSNativeCommandArgumentPassing = 'Legacy'; … }, which has every version pass arguments the 5.1 way for that one command. The command runs unchanged in Windows PowerShell 5.1 and in PowerShell 7.

The same body in all three shells

A raw-text body containing both double quotes and an apostrophe, as the builder escapes it for each shell:

bash / zsh

curl -X POST 'https://api.example.com/notes' --data-raw '{"note":"it'\''s done"}'

cmd.exe

curl -X POST "https://api.example.com/notes" --data-raw "{\"note\":\"it's done\"}"

PowerShell

& { $PSNativeCommandArgumentPassing = 'Legacy'; curl.exe -X POST 'https://api.example.com/notes' --data-raw '{\"note\":\"it''s done\"}' }

Frequently Asked Questions

How do I convert a curl command to Python requests, fetch or Axios?

Paste the curl command into the import box (or straight into the URL field) and choose Python, fetch or Axios above the output. The builder reads the method, URL, headers, auth, body and flags, then writes the same request in that language: json= or data= for Python, JSON.stringify or URLSearchParams for fetch, and auth and data for Axios. Anything that has no equivalent, such as -k in fetch, is called out in a note.

How do I copy a request from Chrome DevTools as curl?

Open DevTools, go to the Network tab, right-click the request and choose Copy, then Copy as cURL (bash) or Copy as cURL (cmd) on Windows. Firefox has the same item under Copy Value. Paste the result into the import box: both the bash form, with single quotes and backslash line endings, and the cmd form, full of ^ escapes, are understood. Browser-copied commands include your cookies and session headers, so remove those before sharing the command.

Which shells are supported?

The builder writes and reads commands for bash and zsh (macOS, Linux, WSL, Git Bash), the Windows Command Prompt (cmd.exe) and PowerShell. Each has different quoting and line-continuation rules, so pick the one matching where you'll paste the command.

Why does a curl command from documentation fail on Windows?

Usually quoting. Most docs are written for bash and use single quotes, which cmd.exe passes through as literal characters. In Windows PowerShell 5.1, curl is an alias for Invoke-WebRequest, which doesn't accept curl's flags. Import the command here and switch the output to cmd or PowerShell: the PowerShell version calls curl.exe directly, which works in every version.

How does Basic auth work in curl?

curl's -u user:password flag sends an Authorization: Basic header containing the base64 of user:password. The builder uses -u rather than writing the header by hand, and when you import a command with an Authorization: Basic header, it decodes it back into the username and password fields. Base64 is an encoding, not encryption, so only send Basic auth over HTTPS.

Which Content-Type does curl send?

With -d or --data-raw and no Content-Type header, curl sends application/x-www-form-urlencoded, even for JSON, which is a common reason APIs reject a request. The builder adds application/json for JSON and GraphQL bodies and application/x-www-form-urlencoded for forms. Multipart forms get multipart/form-data with a boundary from curl itself. Your own Content-Type header always takes precedence.

Why does the builder use --data-raw instead of -d?

With -d, a body that starts with @ is treated as a file name, so a value like @channel would make curl look for a file. --data-raw sends the text exactly as typed. To send a file on purpose, use -d @body.json, or --data-binary @body.json if the file's line breaks must be kept, since -d strips them.

What does the multipart body type produce?

One --form-string 'key=value' flag per text field, which sends the value exactly as typed, even one that starts with @ or <. Tick File on a row to attach a file instead: the builder writes -F 'key=@/path/to/file' and curl uploads that file. In Python the same form becomes files=[…], and in fetch and Axios a FormData object.

How are query parameters encoded?

Each key and value is percent-encoded, so a space becomes %20 and an ampersand becomes %26, then joined onto the URL with ? or & depending on whether the URL already has a query string. Unchecked rows and rows with an empty key are skipped. An API key set to go in the query string is appended the same way.

How does the GraphQL body type work?

It wraps your query and variables into one JSON object with "query" and "variables" fields and sends it with a JSON Content-Type, the format most GraphQL servers expect over POST. Variables must be a valid JSON object; if they can't be parsed, the builder shows the parse error instead of a command. Importing a curl command whose JSON body has just query and variables fills the GraphQL fields.

Why does the command include -X?

So the method is visible at a glance; for GET, and for POST with a body, it's redundant but harmless. HEAD is the exception: the builder writes curl's -I flag instead, because -X HEAD makes curl wait for a body that never comes. Also worth knowing: with -L, -X keeps the same method on every redirect rather than switching to GET after a 301, 302 or 303.

Is my API key or token sent anywhere?

No. Commands and code are assembled in your browser, and nothing you type is sent to a server or saved; only your choice of shell and output language is remembered. The finished command does contain your token in plain text, so keep it out of public issue trackers and remember that your shell saves commands to its history.

Advertisement