curl Command Builder and Converter
Build curl commands and convert them to fetch, Python and HTTPie.
About this tool
Fill in the method, URL, headers, body and auth to get a ready-to-run curl command, or paste an existing curl command to edit it. Every request is also shown as JavaScript fetch, Python requests and HTTPie. Nothing is sent: the tool only writes the commands.
How to use it
- Paste an existing curl command to import it, for example from your browser’s developer tools (Copy as cURL).
- Or set the method and URL, then add headers, auth and a JSON, form or raw body.
- Choose options like following redirects or showing response headers.
- Copy the result as curl, JavaScript fetch, Python requests or HTTPie.
Questions
- How do I send JSON with curl?
- Use -H 'Content-Type: application/json' together with --data-raw '{"key":"value"}'. Newer curl versions also have --json, which sets both the Content-Type and Accept headers for you. Choose JSON as the body type here and the right flags are added.
- Does this tool send my request?
- No. It only writes code. Nothing leaves your browser, so it is safe to paste commands that contain tokens, though it is good practice to replace real secrets with placeholders before sharing a command.
- What is the difference between -d and --data-raw?
- With -d, a value starting with @ is read from a file. --data-raw sends the text exactly as written, which is safer for JSON and for values that may start with @.
- Why does curl not follow redirects?
- By default curl shows the redirect response itself. Add -L (Follow redirects) to go to the new location. fetch and most libraries follow redirects automatically.
- Which curl options can be imported?
- Method, URL, headers, the data options, --json, -u, user agent, cookies, referer, -G, -L, -i, -s, -k, -v, --head and --compressed. Multipart -F fields and other rare options are skipped with a note.
- How do I send form data with curl?
- curl -d "name=Ada&role=admin" URL sends a URL-encoded form and switches the method to POST on its own. Use --data-urlencode "q=hello world" when a value contains spaces or symbols. File uploads need multipart -F "[email protected]", which this tool skips when importing, so add it by hand.
- How do I add query parameters to a curl GET request?
- Put them in the URL and wrap the whole URL in double quotes, because & and ? mean something to the shell. Or keep them separate with -G --data-urlencode "q=red shoes", which appends the encoded values to the URL instead of sending a body. The import here understands -G and moves the values into the URL.
- How do I see the response headers with curl?
- -i prints the status line and headers before the body. -I (--head) sends a HEAD request and shows only the headers, but some servers answer HEAD differently from GET. -v shows the request headers too, plus the TLS handshake, which helps when debugging redirects, auth or certificate errors.
How to convert curl to Python requests
Paste the curl command into the import box and pick Python. Headers become a dict, a JSON body becomes json=payload so requests serialises it and sets the Content-Type, and form or raw bodies become data=payload. Basic auth from -u turns into auth=(user, password), and -k becomes verify=False. A Bearer token stays in the headers as an Authorization entry.
Two lines may surprise you. requests follows redirects by default and curl doesn’t, so the code adds allow_redirects=False unless the curl command had -L. requests also has no default timeout and can wait forever on a stuck server, so timeout=30 is added. Keep it, or change the number. The same request is also available as JavaScript fetch and HTTPie with one click.
Why does a request work in curl but not in fetch?
The usual cause is CORS. curl sends the request and prints whatever comes back, but a browser only lets your page read a cross-origin response when the server allows it with Access-Control-Allow-Origin. Browsers also refuse to set some headers, such as Cookie and Host, from code. The same fetch code run in Node has no CORS checks, so it behaves like curl.
To get a working starting point, open the Network tab in your browser’s developer tools, right-click the request and choose Copy as cURL. On Windows, pick the bash variant, because the cmd variant uses a different escaping style. The copied command carries many browser headers you rarely need, like sec-ch-ua and long cookies, so delete them in the header list before converting.
HTTPie vs curl: syntax compared
curl is installed almost everywhere, including macOS and Windows 10 and later. HTTPie (the http command) has shorter syntax and colours the output. Headers are written as Name:value without -H, form fields as name=value with --form, --follow replaces -L, and --verify=no replaces -k. The generated HTTPie command feeds JSON bodies through a here-string, which works in bash and zsh but not in PowerShell.
For Basic auth, curl -u user:password and HTTPie -a user:password both build the Authorization header for you. The credentials are only Base64-encoded, not encrypted, which the Base64 tool can show, so always send them over HTTPS. For tokens, curl uses -H "Authorization: Bearer TOKEN" and HTTPie uses -A bearer -a TOKEN. When you import a curl command, a Bearer header moves into the Auth fields automatically.
Something not working, or a result looks wrong? Report a problem with this tool