diff --git a/docs/cmdline-opts/write-out.md b/docs/cmdline-opts/write-out.md
index 5b8fdb3e47..2386c321ec 100644
--- a/docs/cmdline-opts/write-out.md
+++ b/docs/cmdline-opts/write-out.md
@@ -193,6 +193,10 @@ known as "http_code"). (Added in 7.18.2)
## `scheme`
The URL scheme (sometimes called protocol) that was effectively used. (Added in 7.52.0)
+## `size_delivered`
+The total amount of data that were saved or written to stdout. When
+--compressed is used, this could very well be different than `size_download`.
+
## `size_download`
The total amount of bytes that were downloaded. This is the size of the
body/data that was transferred, excluding headers.
diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index 2700abfa44..cf2aa08b71 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -461,6 +461,8 @@ static const struct writeoutvar variables[] = {
{ "remote_port", VAR_PRIMARY_PORT, CURLINFO_PRIMARY_PORT, writeLong },
{ "response_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong },
{ "scheme", VAR_SCHEME, CURLINFO_SCHEME, writeString },
+ { "size_delivered", VAR_SIZE_DELIVERED, CURLINFO_SIZE_DELIVERED,
+ writeOffset },
{ "size_download", VAR_SIZE_DOWNLOAD, CURLINFO_SIZE_DOWNLOAD_T,
writeOffset },
{ "size_header", VAR_HEADER_SIZE, CURLINFO_HEADER_SIZE, writeLong },
diff --git a/src/tool_writeout.h b/src/tool_writeout.h
index 4025eaeef6..7bc54aeb4d 100644
--- a/src/tool_writeout.h
+++ b/src/tool_writeout.h
@@ -90,6 +90,7 @@ typedef enum {
VAR_REFERER,
VAR_REQUEST_SIZE,
VAR_SCHEME,
+ VAR_SIZE_DELIVERED,
VAR_SIZE_DOWNLOAD,
VAR_SIZE_UPLOAD,
VAR_SPEED_DOWNLOAD,
diff --git a/tests/data/test220 b/tests/data/test220
index 32d6813c8f..64c11d6331 100644
--- a/tests/data/test220
+++ b/tests/data/test220
@@ -50,7 +50,7 @@ http
HTTP GET gzip compressed content
-http://%HOSTIP:%HTTPPORT/%TESTNUMBER --compressed
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER --compressed -s -w '%{stderr}%{size_delivered}\n'
@@ -67,5 +67,8 @@ Accept: */*
Accept-Encoding: xxx
+
+24
+