Send Empty Header Value Using cURL

When testing or interacting with web APIs, you may occasionally need to send a custom HTTP header that contains no value. This article provides a quick, direct guide on how to send an empty header value using the cURL command-line tool, explaining the correct syntax to use and how to verify your request.

To send an empty header value with cURL, you must use the -H (or --header) option, followed by the header name and a single semicolon (;).

The standard syntax is:

curl -H "Header-Name;" http://example.com

Why use a semicolon?

Normally, cURL defines headers using a colon to separate the name and the value (for example, -H "Content-Type: application/json").

If you try to send an empty header using a colon, such as -H "Header-Name:", cURL interprets this as an instruction to delete or omit that header entirely from the request. This is useful for removing default headers like Host or User-Agent, but it will not transmit an empty header.

To force cURL to send the header with an empty value, you must replace the colon with a semicolon (Header-Name;).

Example Command

To send an empty header named X-Empty-Header to a test server, run the following command:

curl -H "X-Empty-Header;" https://httpbin.org/headers

Verifying the Request

To verify that the empty header is being sent correctly, add the -v (verbose) flag to your cURL command. This allows you to inspect the outgoing request headers.

curl -v -H "X-Empty-Header;" https://httpbin.org/headers

In the verbose output, you will see the header sent with nothing after the colon:

> GET /headers HTTP/1.1
> Host: httpbin.org
> User-Agent: curl/7.81.0
> Accept: */*
> X-Empty-Header: 
>