What is the standard format for a browser's User-Agent string?

The User-Agent header is part of the RFC7231, which is an improved version of the RFC1945, where it states:

The User-Agent request-header field contains information about the user agent originating the request. This is for statistical purposes, the tracing of protocol violations, and automated recognition of user agents for the sake of tailoring responses to avoid particular user agent limitations. User agents SHOULD include this field with requests. The field can contain multiple product tokens (section 3.8) and comments identifying the agent and any subproducts which form a significant part of the user agent. By convention, the product tokens are listed in order of their significance for identifying the application.

EBNF Definitions:

   User-Agent      = "User-Agent" ":" 1*( product | comment )

Where product is defined as:

   product         = token ["/" product-version]
   product-version = token
   token           = 1*<any CHAR except CTLs or separators>

And comment as:

   comment         = "(" *( ctext | quoted-pair | comment ) ")"
   ctext           = <any TEXT excluding "(" and ")">

And other rules, for reference:

   CTL             = <control characters, e.g. ASCII 0x00 through 0x0F and 0x7F>
   separators      = "(" | ")" | "<" | ">" | "@"
                     "," | ";" | ":" | "\" | <">
                     "/" | "[" | "]" | "?" | "="
                     "{" | "}" | SP | HT
   SP              = <ASCII space 0x20, i.e. " ">
   HT              = <ASCII horizontal tab 0x09, aka '\t'>

Note that this means that product strings cannot contain spaces, but comment strings can.


Examples:

Here are some valid examples of product strings (with and without product-version strings):

# Single `product` without product-version:
Foobar
Foobar-baz

# Single `product` with product-version:
Foobar/abc
Foobar/1.0.0
Foobar/2021.44.30.15-b917dc

Here are some valid examples of comment strings; note how all strings are enclosed in matched parentheses ( ):

# This was the default `comment` used by Internet Explorer 11:
(Windows NT 6.1; WOW64; Trident/7.0; rv:11.0)

# You can put almost any text inside a comment:
(Why are you looking at HTTP headers? Go outside, find love, do some good in the world)

# Note that `comment` strings can also be nested, provided their delimiting parentheses are matched, for example:
(Outer comment (Inner comment))

As a User-Agent header's value is comprised of arbitrary product and comment strings, these are all valid User-Agent headers:

User-Agent: Foobar
User-Agent: Foobar/2021.44.30.15-b917dc
User-Agent: MyProduct Foobar/2021.44.30.15-b917dc
User-Agent: Tsom/OfraHaza (Life is short and love is always over in the morning) AnotherProduct

This is specified in RFC 1945 in the section on Request Headers. It is not a very standardized format, though, and user agents tend to put whatever they want in there.