curl Command Builder
Build a curl command from a URL, method, headers and body, with the flags that matter for debugging.
Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.
What the curl Command Builder does
Use this curl command builder to build a curl command from a URL, method, headers and body, with the flags that matter for debugging. Paste your text in, pick the options you need, and copy the result straight back out. It is most often used for testing an API endpoint from the terminal. For a second version of this curl command builder, see FreeToolStation.org.
How to use it
- Enter the URL and pick the method.
- Put the request body in the input box for POST, PUT or PATCH.
- Set the Authorization header value, replacing the placeholder with a real token at the terminal rather than here.
- Copy the command.
How it works
Two flag choices make the difference between a usable curl command and a confusing one. Without -L, curl prints the 301 response rather than following it, which looks like a failure. Without -f, curl exits with status zero even on a 500, so a script that checks the exit code will think the request succeeded.
--data-raw rather than -d matters when the body contains newlines or begins with an @ sign. Plain -d strips newlines and treats a leading @ as a filename to read, which is surprising behaviour in a JSON body.
Never put a real token on a curl command line you will run more than once. It lands in your shell history file and is visible in the process list to any other user on the machine. Read it from an environment variable instead, and quote the header with double quotes so the variable expands.
The timing output is the quickest way to find out where a slow request is spending its time: DNS resolution, TCP connect, TLS handshake, or waiting for the server to start responding. Those four numbers usually identify the problem immediately.
When to use it
- Testing an API endpoint from the terminal.
- Reproducing a request outside your application.
- Diagnosing where a slow request is spending time.
- Writing a request into documentation or a bug report.
Common mistakes to avoid
- Putting a real token on the command line, where it enters shell history.
- Omitting -f in a script, so curl exits zero on an HTTP error.
- Using -d instead of --data-raw for a body with newlines or a leading @.
Frequently asked questions
How do I send JSON with curl?
Set a Content-Type: application/json header and pass the body with --data-raw. The method defaults to POST once a body is present, but set it explicitly for clarity.
Why does curl not follow my redirect?
Because -L is not set. Without it, curl prints the redirect response itself rather than following it.
How do I keep an API token out of my shell history?
Read it from an environment variable: -H "Authorization: Bearer $API_TOKEN" with double quotes so it expands. A literal token on the command line is saved to history and visible in the process list.