DEV Community


Posted on


Basic curl options


Here are some super basic curl command options all web-application-developers should know.
If there is/are any other command option/options, you think, should be on the list, plz leave a comment below with the option/options.

Add headers

You can use -H to add headers to your request.

$ curl -H "Content-Type: application/json" http://localhost:8888
Enter fullscreen mode Exit fullscreen mode

Make a POST request with Parameters

You can make a post request with parameters with the -d (-data) flag.
You can specify the method you want to use with -X. In this case, you are specifying to use the POST method.

$ curl -d '{"name":"value1", "content":"value2"}'  -X POST http://localhost:3000
Enter fullscreen mode Exit fullscreen mode

Get verbose response

You can get verbose response with the -v option. The -v stands for -verbose.

$ curl -v http://localhost:8888
Enter fullscreen mode Exit fullscreen mode

Fetch only the HTTP headers

You can use -I/--head flag to only fetch the headers.

$ curl -I http://localhost:8888
Enter fullscreen mode Exit fullscreen mode

Add cookies

You can pass the data to the HTTP server as a cookie with the -b/--cookie command.
NOTE that the file specified with -b/--cookie is only used as input. No cookies will be stored in the file. To store cookies, use the -c/--cookie-jar option

$ curl -c cookie.txt -b cookie.txt -b "name=value"
Enter fullscreen mode Exit fullscreen mode

Send Data like sending them via forms

This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the content-type multipart/form-data according to RFC1867.

$ curl -F title="Test" -F author="Test" -F attachment-file=@test.txt http://localhost:8880
Enter fullscreen mode Exit fullscreen mode


Here are some resources to know more about the curl command.

Top comments (5)

pranay_rauthu profile image
pranay rauthu

writing curl commands is pain. I have created a tool to generate them.

helenat59930026 profile image
Helena Thompson

It is said that the retro style of design will never go out of fashion and always be popular among women. It is simple but still gives an eye-catching look and people like it because they are not complicated as other holiday nail styles.

tomusa0106 profile image

The posts on the site are great. today is my first time on this site, krunker I am very impressed with your post. Thank you for sharing so much useful information.

jimmydean9 profile image
Jimmy Dean

I don't even understand some of the details in this article, but there is some amazing information for me. I am aiming to build an engaging attractive website named wordle unlimited wordle and I got some ideas after reading this article. Thank you.

meave9786 profile image

Hope you guys can be see this amazing blog online here how to get free robux without human verification save to batter way of enjoy.