HTTP Structured Fields Reference

RFC 8941 structured header item, list and dictionary syntax with sf-* types.

Reference for RFC 8941 HTTP Structured Fields covering items, lists, dictionaries, parameters and the bare-item types, with a live parser that classifies a header value.

What are the top-level structured field types?

RFC 8941 defines three: an Item (a single bare item with optional parameters), a List (a comma-separated sequence of items or inner-lists), and a Dictionary (comma-separated key=value pairs). A header's specification fixes which of the three it uses.

A typed grammar for HTTP headers

Historically every HTTP header invented its own ad-hoc syntax, making parsers fragile. RFC 8941 Structured Field Values defines a small, typed grammar so new headers can be parsed uniformly. This reference explains the three top-level types, the bare-item types and parameter syntax, with a live parser that classifies any value you paste.

How it works

A header’s spec declares it as one of three top-level types:

Item:       Content-Length: 42
List:       Accept-Encoding: gzip, br;q=0.8, *;q=0.1
Dictionary: Cache-Status: ExampleCache; hit, ExampleCache2; fwd=uri-miss

Each member is a bare item of a fixed type — Integer, Decimal, String (double-quoted), Token (unquoted), Byte Sequence (:base64:) or Boolean (?1/?0) — optionally carrying ;key=value parameters. An inner list wraps several items in parentheses as one member. The parser below detects the top-level type heuristically (a top-level = outside quotes implies a Dictionary; a comma implies a List; otherwise an Item) and reports each member.

Tips and notes

  • Strings are double-quoted and may only contain printable ASCII; Tokens are unquoted.
  • A bare parameter key (;sni) is shorthand for ;sni=?1 (Boolean true).
  • Byte sequences are base64 wrapped in colons: :cHF=:.
  • Decimals have at most three fractional digits; larger precision needs a String.
  • Use Structured Fields for new headers so generic libraries can parse them safely.