JSON schema

Node#

{
  "codec": "hex" | "dump" | "base64" | "pem" | "bundle" | "jwt" | "gzip" | "zlib"
         | "zstd" | "protobuf" | "der" | "cbor" | "msgpack" | "utf8" | "bytes",
  "alphabet": "std" | "url", "padded": bool,   // base64 only
  "label": "CERTIFICATE",                      // pem only
  "style": "xxd" | "hexdump",                  // dump only
  "start": N,                                  // dump only, when the dump
                                               // starts at a nonzero offset
                                               // (child ranges stay 0-based)
  "kind": "jws" | "jwe",                       // jwt only
  "name": "msg.bin",                           // gzip only, when the header has FNAME
  "range": [start, end],                       // half-open, in the parent buffer
  "confidence": 0.95,                          // 0..1, confidence in `codec`
  // exactly one of:
  "decoded_len": N, "child": Node,             // hex | dump | base64 | pem | gzip | zlib | zstd
  "fields": [Field],                           // protobuf
  "items": [Element],                          // der
  "items": [Value],                            // cbor | msgpack
  "parts": [Node], "times": {"exp": "..."},    // jwt | bundle (times: jwt only)
  "text": "...", "truncated": true?,           // utf8 (capped at 1024 chars)
  "len": N, "hex": "...", "truncated": true?,  // bytes (hex capped at 64 bytes)
  "warnings": [Diag]                           // omitted when empty
}

Field#

{ "field": 1, "wire": "VARINT" | "I64" | "I32" | "LEN" | "GROUP", "range": [s, e],
  // VARINT: every view, as decimal strings
  "uint": "18446744073709551614", "int": "-2", "sint": "9223372036854775807",
  // I64
  "fixed64": "…", "sfixed64": "…", "double": 1.5,
  // I32
  "fixed32": 7, "sfixed32": 7, "float": 1.5,
  // LEN
  "len": 3, "alts": [Alt],
  // GROUP
  "fields": [Field] }

Alt (LEN interpretations, best first)#

{ "as": "message", "score": 0.67, "fields": [Field] }
{ "as": "string", "score": 0.95, "value": "...", "decoded": Node? }  // decoded: string is itself hex/base64/PEM
{ "as": "packed_varint", "score": 0.31, "values": ["8", "150"] }
{ "as": "packed_fixed32", "score": 0.94, "values": [1069547520], "floats": [1.5] }
{ "as": "packed_fixed64", "score": 0.87, "values": ["4632445839417212613"], "doubles": [51.5074] }
{ "as": "bytes", "score": 0.02, "hex": "...", "decoded": Node? }  // decoded: raw bytes are another format
{ "as": "empty", "score": 1.0 }

Element (DER)#

{ "tag": "SEQUENCE",          // universal type name, or "[0]", "[APPLICATION 3]", "[PRIVATE 1]", "[UNIVERSAL 31]"
  "range": [s, e],            // whole element, header included
  "len": N,                   // content length
  // constructed (SEQUENCE, SET, [n] constructed):
  "children": [Element],
  // BIT STRING / OCTET STRING whose content is itself clean DER:
  "unused_bits": 0,           // BIT STRING only
  "encapsulated": true, "children": [Element],
  // primitives, by universal type:
  "int": "-1",                // INTEGER, ENUMERATED: decimal string, up to 16 bytes
  "hex": "…",                 //   … plus hex when longer than 8 bytes (hex only above 16)
  "bool": true,               // BOOLEAN
  "oid": "2.5.4.3", "name": "commonName",   // OBJECT IDENTIFIER / RELATIVE-OID; name when known
  "value": "…",               // character strings (BMP/Universal/T61 decoded to UTF-8)
  "value": "200904000000Z", "iso": "2020-09-04T00:00:00Z",  // UTCTime, GeneralizedTime
  "unused_bits": 3, "hex": "…",            // BIT STRING (not encapsulated)
  "hex": "…", "text": "…"     // anything else (OCTET STRING, [n] primitive, …); text when printable UTF-8
}

Element ranges are absolute within the DER buffer, including elements inside encapsulating BIT/OCTET STRINGs. NULL has no value key.

Value (CBOR / MessagePack)#

A cbor or msgpack node carries "items": [Value] (normally one item; a forced sequence may hold several). Each value has a type, a range in that buffer, and "indefinite":true when it used a CBOR indefinite-length form.

{ "type": "uint" | "nint" | "float" | "bool" | "null" | "undefined"
         | "simple" | "bytes" | "text" | "array" | "map" | "tag" | "ext",
  "range": [s, e],
  "indefinite": true?,                        // CBOR indefinite-length form
  "value": "42",                              // uint/nint: decimal string (nint = -1-n)
  "value": 1.5, "width": 16,                  // float: shortest form that round-trips at the source width 16|32|64 (16-bit uses the f32 form)
  "value": true,                              // bool
  "value": 16,                                // simple (CBOR)
  "len": N, "hex": "…", "truncated": true?, "decoded": Node?,  // bytes
  "value": "…", "truncated": true?,           // text (capped at 1024 chars)
  "items": [Value],                           // array
  "entries": [{"key": Value, "value": Value}],// map
  "tag": "1", "name": "epoch",                // CBOR tag; name when known
  "iso": "…", "int": "…", "uuid": "…",        // tag 1 / 2,3 / 37 extras
  "value": Value,                             // tag payload
  "ext_type": -1, "len": N, "hex": "…", "iso": "…"  // MessagePack ext; iso for the timestamp type (-1)
}

A bytes value's decoded node starts a new buffer at those bytes and is set when they are themselves CBOR/MessagePack/DER/protobuf/compressed, or a text encoding (never for plain text or opaque bytes). It is also set to a bytes leaf that carries a warning (a corrupt or over-budget compressed stream, an unsupported format), so the warning is not lost.

MessagePack maps onto the same tree: positive and negative integers become uint/nint (negatives keep the -1-n form, so int64 min is -9223372036854775808), floats keep width 32 or 64, str must be valid UTF-8, bin is bytes, and ext is ext whose iso is produced for the timestamp type -1 (4-, 8- and 12-byte forms; the 12-byte form allows dates before 1970). Trailing zero digits are trimmed from the nanosecond fraction.

CBOR known tag names: 0 datetime, 1 epoch, 2 bignum, 3 negbignum, 4 decimal, 5 bigfloat, 21/22/23 base64url/base64/base16, 24 cbor, 32 uri, 37 uuid, 55799 self-describe. Tag 1 adds iso (its numeric value as ISO-8601 UTC); tags 2/3 add int (a decimal bignum); tag 37 with 16 bytes adds uuid; tag 24 forces the byte string's decoded node to CBOR.

An iso string (CBOR tag 1, MessagePack timestamp, JWT exp/nbf/iat) is emitted only when the year is inside RFC 3339's 0000..=9999; out-of-range epochs (e.g. i64::MIN, or a year past 9999) omit it rather than print a malformed date.

JWT#

{ "codec": "jwt", "kind": "jws",             // "jws" = 3 parts, "jwe" = 5
  "range": [0, N], "confidence": 0.97,
  "parts": [                                 // one base64 layer node per segment
    { "codec": "base64", "alphabet": "url", "padded": false,
      "range": [s, e],                       // the segment's range in the token
      "decoded_len": L, "child": Node }      // header/payload are utf8 JSON text
  ],
  "times": { "exp": "2026-11-12T09:30:00Z", "iat": "..." }  // omitted when none
}

A JWS payload that is a JSON object contributes its top-level integer exp, nbf and iat claims as ISO-8601 UTC strings, always in exp, nbf, iat order and only when present. A fractional part is truncated toward zero; exponent notation, non-numbers and i64 overflow are ignored. Nested claims (inside objects/arrays/strings) are never read. JWE tokens carry no times.

Bundle (PEM)#

{ "codec": "bundle", "range": [0, N], "confidence": 0.99,
  "parts": [                                 // one pem layer node per block, in order
    { "codec": "pem", "label": "CERTIFICATE",
      "range": [s, e],                       // BEGIN line start .. END line end
      "decoded_len": L, "child": Node }      // child parsed from the block's DER
  ]
}

A single PEM block stays a plain pem node. Two or more blocks become a bundle. Each part's range is its block's BEGIN..END extent in the input text and its child starts a new buffer at the block's decoded bytes. A TRAILING_DATA warning is emitted once, on the bundle, when non-whitespace text sits outside all blocks; the message reports the number of ignored bytes.

A realistic truncated paste (a good block followed by a cut-off one) is not discarded: the blocks decoded so far are kept and the break becomes a warning on the resulting node — PEM_UNTERMINATED (offset at the cut-off BEGIN) or the base64 error. The text from the broken block onward is excluded from the TRAILING_DATA count. If the first block is broken, nothing is recognised and the input stays text.

Number encoding#

  • 64-bit integers (varint views, fixed64, sfixed64, packed values) are decimal strings. JavaScript and jq parse JSON numbers as doubles and would silently corrupt values above 2^53.
  • 32-bit integers are plain JSON numbers.
  • Floats use the shortest round-trip form, or exponent form when very large or very small. NaN and ±infinity are the strings "NaN", "Infinity" and "-Infinity".

Ranges#

A range points into the buffer the node or field was parsed from:

  • A layer node's child is parsed from that layer's decoded bytes.
  • Protobuf fields at any nesting depth use offsets into the same message buffer, so nested fields have absolute offsets within it.
  • A string or bytes alt's decoded node starts a new buffer at the field's bytes.
  • A JWT part's child starts a new buffer at that part's decoded bytes.
  • A PEM bundle part's range is its block in the input text, and its child starts a new buffer at the block's decoded bytes.
  • DER elements at any nesting depth (encapsulated ones included) use offsets into the same DER buffer.
  • CBOR / MessagePack values use offsets into the same buffer; a bytes value's decoded node starts a new buffer.