๐ curl Command Builder
curl \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"name": "Alice"
}' \
'https://api.example.com/v1/users'Fill in an HTTP method, URL, request headers, and request body, and this tool automatically generates the matching curl command. Handy for quickly preparing a correctly shell-escaped curl command while testing or debugging an API.
How to use
- Enter the HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD) and URL.
- Add any request headers you need.
- For POST, PUT, or PATCH, enter a request body โ the curl command is generated automatically.
How the calculation works
curl sends HTTP requests from the command line. Enter a method, URL, headers and body, and this tool builds a curl command you can paste straight into a terminal. โข -X: the method (GET, POST, PUT, PATCH, DELETE, HEAD) โข -H: a header, as "Name: value" โข -d: the request body (added only for POST, PUT and PATCH) Values are wrapped in single quotes, and any single quote inside a value is replaced with '\'' so the shell does not interpret special characters. Long commands are split across lines with a trailing "\" for readability.
Worked example
Default output curl \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "name": "Alice" }' \ 'https://api.example.com/v1/users' When sending JSON to an API, it is usual to set the Content-Type header to application/json.
Things to be aware of
- The command uses syntax for macOS and Linux shells (bash, zsh). Windows Command Prompt does not support single quotes, so use PowerShell or WSL, or switch to double quotes.
- Commands containing API keys or other secrets end up in your shell history. Remove them before sharing.
- Since curl 7.82, the --json option sets both the Content-Type and Accept headers for you.
FAQ
Can I run the generated command directly in a terminal?
Yes, it's output with proper single-quote shell escaping, so you can copy and paste it directly into bash/zsh or another Unix shell.
Can I add an Authorization header?
Yes, enter "Authorization" as the header key and something like "Bearer your-token" as the value to generate a command with an auth header.
Can I send a body with a GET request?
No, this tool only shows the body input field for POST, PUT, and PATCH methods.