← All tools

cURL Command Builder

Build a cURL command from a form, quoted correctly for macOS, Linux or Windows, or copy it as fetch().

Free tool No account

• The body is JSON, so Content-Type: application/json was added.

Command
curl 'https://api.example.com/v1/items' \
  -L \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "name": "Notebook",
  "price": 4.5
}'
ReadyProcessed locally · No upload
Enjoying cURL Command Builder?Your review and ideas shape what we build next.

Review cURL Command Builder

Please don't include file contents or passwords.

About the cURL Command Builder

Fill in a method, address, headers and body and get a ready-to-run cURL command, with the quoting done correctly for your terminal: macOS and Linux, Windows Command Prompt or PowerShell. Add a username and password or a bearer token, follow redirects, and copy the same request as JavaScript fetch() code.

How to use it

  1. Choose the method (GET, POST, PUT, PATCH, DELETE, HEAD or OPTIONS) and type the URL.
  2. Add headers, one per line as Key: Value, and a body if you're sending data.
  3. Pick a login type if the API needs one, and tick the options you want.
  4. Choose your terminal, then copy the command, or switch to JavaScript fetch() for code.

Tip: The command uses --data-raw instead of -d. With -d, a body that starts with @ makes cURL read a file from your disk; --data-raw always sends exactly what you typed.

cURL options explained

-X POST
Sets the method. It isn't needed for GET, or for POST when there's a body, so the tool leaves it out then.
-H 'Key: Value'
Adds a header. Repeat it for each header.
--data-raw '…'
Sends a request body exactly as typed.
-u user:password
HTTP basic login. cURL encodes it as an Authorization: Basic header.
-L
Follows redirects (301, 302, 307, 308) to the final address.
-i
Shows the response headers above the body: the status code, content type and cookies.
--compressed
Asks for a gzip or Brotli response and unpacks it, like a browser.
-I
Sends a HEAD request: headers only, no body. Use it to check a status code or redirect quickly.

Quoting on Windows, macOS and Linux

Each terminal treats quotes differently, which is the most common reason a copied cURL command fails. On macOS, Linux, Git Bash and WSL the tool wraps values in single quotes, and a ' inside a value becomes '\''. Lines end with \ so a long command stays readable.

Windows Command Prompt has no single quotes, so values go in double quotes, inner double quotes become \", lines end with ^, and a multi-line JSON body is put on one line. PowerShell gets curl.exe (plain curl is a different command there), single quotes with '' for a quote inside, and a backtick ` at the end of each line. In the older Windows PowerShell 5.1, quotes inside JSON can be lost; use Command Prompt there.

Sending JSON to an API

Choose POST, PUT or PATCH and paste the JSON into Body. When the body is valid JSON and there's no Content-Type header, the tool adds Content-Type: application/json for you, because most APIs reject JSON without it. A GET or HEAD request can't carry a body, so the tool leaves the body out and tells you.

Common API recipes

Call an API with a token
Login: Bearer token. The tool adds Authorization: Bearer <token>.
Check where a short link goes
HEAD with follow redirects ticked, or GET with -i to see each response.
Debug a failing request
Tick show response headers and look at the status code; then look it up in the HTTP status code tool.
Send a form
POST with the header Content-Type: application/x-www-form-urlencoded and a body like name=Sam&city=Paris.

From cURL to JavaScript

Switch to JavaScript fetch() for the same request as code you can paste into the browser console, Node.js 18 or later, Deno or Bun. A JSON body becomes JSON.stringify({…}), headers become an object, and a basic login is turned into its Authorization header. Browsers block some headers, such as Cookie and Host, and cross-site requests need the server to allow them (CORS).

Reading the response

Status line
With -i, the first line, such as HTTP/2 200, gives the status code. Look up anything unexpected in the HTTP status code tool.
Content-Type
Tells you what the body is: application/json, text/html, image/png…
Location
On a 3xx response, where the redirect points. Tick follow redirects to go there automatically.
Retry-After
On 429 or 503, how many seconds to wait before trying again.

Tips and tricks

Spaces in the address

The tool encodes them as %20 and adds https:// when it's missing.

An empty header

Key: with nothing after it makes cURL delete that header; the tool writes Key; so it's sent empty, as you meant.

Save the response

Add -o file.json to the end of the command to write the response to a file.

See everything

Add -v to the command to see the full conversation with the server, including TLS.

Questions

Is cURL installed on Windows?

Yes. Windows 10 and 11 include curl.exe; run it from Command Prompt or PowerShell. macOS and most Linux systems have curl already.

Why does my JSON body fail on Windows?

Usually the quotes: Command Prompt needs the inner double quotes written as \". Choose Windows Command Prompt in the tool and copy that version.

Is my token safe?

The command is built in your browser and nothing is sent anywhere. The token is part of the command, though, so take care where you paste or share it.

What's the difference between -d and --data-raw?

Both send a body. -d treats a value starting with @ as a file name to read; --data-raw never does.

How do I send a file with cURL?

Use -F 'file=@photo.jpg' for a form upload or --data-binary @file.json for a raw body. Add these to the copied command; the builder sends typed text only.

Is anything I type uploaded?

No. The tool runs in your browser; what you type or paste never leaves your device and nothing is stored on a server.

Related tools

Updated