curl command is used to interact with a web server. It can be used to fetch content from or post data to a HTTP endpoint. Consider it to be a command line web browser without a GUI. It can do pretty much everything that a web browser can do except that it:

  • doesn’t display pretty web pages, its a linux cli command afterall
  • doesn’t run javascript on the page

Listed below are the most common usage of curl. Refer to the official documentation for an exhaustive list of options and flags.


Most basic usage

$ curl
#=> issues a GET request and outputs html souce of website

POST request

# With data (-d or --data)
$ curl -d 'username=john&password=secret'
#=> issues a POST request with POST parameters username=john and password=secret
#   Use this to POST form fields with "content-type: application/x-www-form-urlencoded"

# Without data
$ curl -d ''
# or
$ curl -X POST

# Upload file (-F or --form)
$ curl --form "[email protected]"

# Upload file as well as desired target filename plus send post params
$ curl --form "[email protected];filename=display-pic.jpg" --form username=john --form password=secret

Curl with proxy

# use a http proxy (-x or --proxy)
$ curl -x
$ curl -x

# or the usual linux way by setting the env variable
$ http_proxy= curl
# note that for https webpages, the command will be
$ https_proxy= curl