Skip to content

The KV format

The KV format is a key-value text format that’s basically JSON without the JavaScript compatibility.

KV data consists of zero or more “{key}={value}” entries.

Values in KV are

  • the keywords true, false or null,
  • a JSON-compatible double quoted string, or a single quoted one.
  • a JSON number.
  • a value which can contain almost anything but spaces or delimiting characters like brackets [], braces {}, or commas ,.
  • an array, starting with [ and ending with ], with a series of values separated by whitespace and maybe a comma.
  • an object, starting with { and ending with }, with a series of key=value and/or key: value fields separated by whitespace and maybe a comma.

Delimiters in KV are whitespace (spaces,tabs,newlines), brackets ([]), braces ({}) and commas (,). The equals (=) and colon (:) characters are sometimes-delimiters, they can appear on the value side but cannot appear in unquoted keys.

Most URLs can be represented unquoted in KV. Where keys are allowed, quoted strings can be used to include characters.

For example, kv values can preceed an HTTP request because GET is not followed by =.

a=b
c=d
GET https://example.com

This format is accepted at the top of any pardon .http template and allows us to specify values directly above the request without additional syntax.

The main advantages of the KV format are

  • less syntax than JSON (quotes / commas can be elided in many cases).
  • Human readable - easy to read and write.
  • JSON compatible values - easy to generate

KV Playground

Try experimenting here