Skip to content

curl cheatsheet

Basic usage


GET request


Enable compression

curl --compressed


Simple POST data

curl -d name=x

Multiple parameters

curl -d name=x -d surname=y
curl -d 'name=x&surname=y'

Raw data (no special interpretation of @ character)

curl --data-raw "@at"

URL-encoded data

curl --data-urlencode name=val

Binary data

curl --data-binary @filename


curl --json '{"foo": "bar"}'

Chunked encoding

curl -H "Transfer-Encoding: chunked" -d @file

Send output of the command in POST request

uname -a | curl -XPOST -d @-

HEAD request

curl -I


curl -T localfile

Save output to the file

Write output to the file

curl -o file.html

Write output to the file, use remote file name

curl -O

Do not overwrite existing files

curl --no-clobber -o file.png

Skip TLS certificate validation

curl -k

Silent output

curl -s

Fail fast with no output at all on server errors

curl -f

Do not handle sequences of /../ and /./ in the URL.

curl --path-as-is


Connect via proxy

curl -x

Socks 4a

curl --socks4a hostname:1080

Socks5 proxy

curl --socks5 proxy.example:1080

Set username and password for proxy authentication

curl --proxy-user username:pass -x

Set HTTP headers

Set Cookie value

curl -b cookie=value

Set User-Agent

curl -A "New User Agent"

Set referer

curl -e "https://test.example"

Set header

curl -H "User-Agent: Hello"
curl -H 'X-Custom-Header: HeaderValue'

Set Content-Type

curl -d '{}' -H 'Content-Type: application/json'

Send a file

Send file as form

curl -F "file=@/path/to/file"
curl -F "x=`cat /path/to/file`"
cat /path/to/file | curl -F ":data=@-"

Upload file

curl -T /path/to/file

Send in POST body

curl -XPOST -d @/path/to/file

Send binary data in POST body

curl --data-binary


Send file via FTP

curl -T /path/to/file ftp://server -u user:password