Overview
Reference usage
One card for any payload: a header row with a Fields / JSON switch at the start and the count and a single copy action at the end, and a body under a divider. Fields is the default, with sentence-case labels; JSON is the escape hatch and always shows the stored payload with its raw keys.
Overview
PayloadInspector composes SegmentedControl, CopyButton, JsonViewer, Table, Badge, Button and CodeBlock into one component for operational dashboards: workflow engines, tool calls, API consoles, webhook debuggers. Pass any JSON-serializable value, or the JSON text itself; the inspector parses it, hides secrets, chooses a layout, and handles every state.
What the Fields view draws:
- Nothing to show: one muted line (
emptyLabel), with no card, no switch and no copy button. - A value that is not an object: the value alone, in monospace. The header reads "1 value".
- A few short pairs: one line, "Order ID 4471, Amount $42.00", labels regular and values bold. The line wraps at the card's width and never cuts a value; its
titlestill carries the whole text. - Many short pairs: a wrapping key and value grid sized to its content.
- Anything else: one pair per row. A nested object is a collapsible tree (objects open, arrays closed); an array of scalars is a bulleted list; an array of objects that share keys is a table with real headers, capped at eight rows with "Showing 8 of 2,140" and Load more; an array of objects that do not share keys is one block of fields per item, headed "Item 1 of 3".
- Long text clamps to two lines with Show all, and a unified patch goes through the diff viewer.
Fields formats only what the JSON says unambiguously: an ISO date reads "Oct 24, 2026", a boolean "Yes" or "No", null "None", an empty string "Empty". A number reads as stored; anything else (cents as dollars) comes from formatValue, keyed by path.
The header counts top-level keys in words ("1 field", "3 fields"), adds the size only above 1 KB ("2 fields, 1.4 KB"), and a nested label carries its own count ("Parts, 3 items").
States, in the order they win over each other:
failed: the switch is hidden, Copy is disabled, and a red line says what failed, with a Try again button whenonRetryis passed.- No value: the muted line above.
- A value that can't be serialized (circular references, BigInt): an explanation, with no switch and no copy.
- Over
maxBytes(1 MB by default): nothing is rendered. The header holds only the size and Copy, and the body offers Download JSON. - Text that is not valid JSON: the switch shows disabled, the header reads "Text", an amber line says so, and the raw text follows in a code block. Copy reads "Copy text".
streaming: pass the JSON text received so far. Fields appear as they complete, the last one shows "Receiving…", the count reads "2 fields so far", and Copy waits.
Usage
label is optional. When given, it is drawn at the start of the header (before the switch) and names the card; without it the card is named "Payload".
With a JSON string
When your data arrives as a serialized string (e.g. from a message queue or API response body), pass it directly. The component parses it automatically:
With truncation flag
When the producer truncates a payload before sending (e.g. due to wire limits), set truncated to signal this to the reader:
Copy behavior
The copy button in the header copies pretty-printed JSON of the parsed value. When the payload itself is a string, including a JSON-encoded string primitive like '"hello"', it copies that original string verbatim instead, so the copied text always matches what was passed as value. Unless a secret in it was hidden: then the hidden copy is written, so Copy never holds a stored secret. After a copy, the icon turns into a check with the word "Copied" for two seconds, announced politely, with no toast.
Hiding secrets
Pass the secret paths as redact. Those values are hidden in both views and in Copy before anything is laid out: Fields shows bullets and the word "Hidden", and JSON and Copy hold bullets.
A path is dot-separated property names from the root, array positions count from 1, and * stands for any one name or position (headers.authorization, attachments.*.token). When redact is not passed, a property whose name reads as a secret (token, key, password, authorization) is hidden as a fallback, because nothing else says which values are. Pass [] to hide nothing. Text that is not valid JSON cannot be searched for secrets, so it is shown as written.
Writing a value your own way
formatValue receives { path, key, value } and returns the text to show, or undefined to keep the default. It only changes the Fields view.
Custom parser for non-JSON formats
Pass a parse function to support alternative serialization formats:
Showing a value as text
Set plain to show a string as it is: text in a code block under the label, with no Fields / JSON switch, no parsing and no invalid-JSON notice. Use it for a value that is not JSON, or one too long to lay out as fields, and say what it is in the label.
Keeping internals in the JSON view
Name top-level properties in jsonOnly to leave them out of the Fields view while the JSON view still shows every one. The Fields list ends with a muted "1 more in JSON" line so nothing hides silently, and the header counts all the top-level fields and says how many are JSON only.
Accessibility
The root is a named group, not a landmark, so a dashboard rendering many inspectors adds nothing to the screen reader's landmark list. The label (or "Payload") names it, and the JSON tree is cinder's JsonViewer, a WAI-ARIA tree composite; see json-viewer accessibility documentation for its keyboard contract.
A failed load carries role="alert". The copy confirmation is announced by the copy button's own polite live region. See payload-inspector.a11y.md for the full pattern.
- User ID
u_8f2a3b- Action
- checkout
- Total
- 89.93
- Timestamp
- Jun 11, 2026, 2:22 PM
- Guest checkout
- No
- Promo applied
- Yes
When to use
- Inspecting workflow inputs, signal payloads, activity results, or API response bodies in a dashboard.
- Displaying a structured payload with a visible label, byte size, and copy affordance.
- Reading a payload as data first, with the raw JSON one switch away.
- Reading a few short pairs as one line that wraps at the card's width and never cuts a value.
- Rendering a raw code block only — use code-block directly instead.
- Needing search, filtering, or virtualization over large collections — compose a custom viewer.
Examples
Basic payload inspector
Inspect a structured object payload as an interactive tree with a copy action and byte size.
Edge cases
Demonstrates the empty, null, invalid JSON, truncated, scalar, streaming, secret, oversize and failed states of the inspector.
Empty, none and yes or no
An empty string reads "Empty" and null reads "None", both in muted italics. Booleans read "Yes" and "No". The JSON view keeps "", null, false and true.
The payload fails to load
When the payload cannot be loaded the card keeps its header, hides the switch, shows Copy disabled, and the body says so in red with a Try again button.
Invalid JSON
When the stored value cannot be parsed, Fields is unavailable and the switch is disabled, the header reads "Text" in place of a count, and a warning sits above the raw text. Copy still works and reads "Copy text".
The JSON view
The JSON view is a flat code block with a faint fill, muted keys and no border inside the card. It always shows the stored payload with its raw keys.
A long key and a long unbroken value
A key too long for its column cuts to one line with an ellipsis, and a tooltip carries the whole key with its length. A value with no spaces breaks anywhere and never overflows the card.
Long text
Text longer than two lines clamps with Show all and is never squeezed into a grid column. A payload over 1 KB adds its size to the count, and the JSON view keeps the stored text with its \n escapes.
Many short pairs
Eight short pairs wrap into a key and value grid sized to its content, not stretched across the card. Dates read as dates and everything else as stored.
An array of mixed objects
When array items do not share keys no table is drawn: each item is its own block of fields, headed "Item 1 of 3" and so on. Only a uniform array becomes a table.
One-line summary
A few short pairs read as one line that wraps at the card's width and never cuts a value.
Over the size limit
Over the maxBytes limit the card renders nothing and shows no switch: the header holds only the size and Copy, and the body says why with a Download JSON button.
A patch in the payload
A unified patch goes through the diff viewer: line breaks stay, the first two changed lines show, the count sits beside the label and Show all opens the rest. A file path is set in monospace.
Secrets masked by key name
With no schema to say which values are secret, a property whose name reads as one (token, key, password, authorization) is masked as a fallback. Pass redact to name the secret paths, or an empty list to hide nothing.
Secret fields masked
Values the caller names as secret paths are masked in both views and in Copy before any layout runs: the Fields view shows bullets and the word "Hidden", and the JSON view shows bullets. Secrets are never revealed here.
Shapes of data
A few short pairs read as one line, a nested object as a collapsible tree, an array of scalars as a bulleted list, and an array of uniform objects as a table with Load more.
Signal payload
Inspect a workflow signal payload — a common pattern in activity result dashboards.
A single value
A payload that is not an object shows the value alone: no key and no grid, the count reads "1 value", and the JSON view quotes it.
Still streaming in
While a payload streams, fields appear as they complete and the last shows a spinner with "Receiving…". The count reads "so far", Copy waits for the end, and the JSON view shows the partial text.
Workflow input
Inspecting a workflow launch payload with signal input, retry policy, and schedule metadata.
Props
Name | Type | Default | Description |
|---|---|---|---|
value | unknown | The payload value to inspect. Pass any JSON-serializable value — object,
array, string, number, boolean, or null. Plain strings are rendered as
string values; strings that look like serialized JSON are parsed, and one
that does not parse is shown as text. Pass undefined when there is no
payload, which draws one muted line and no card. While streaming, pass
the JSON text received so far. | |
truncated | boolean | false | When true, the payload has been truncated by the producer (e.g. because it exceeded a wire size limit). The inspector renders a truncation badge in the header. |
initialDepth | number | 1 | Initial collapse depth. In the JSON view, nodes deeper than this start collapsed; in the Fields view, an object nested deeper than this starts collapsed. Defaults to 1. |
maxDepth | number | 50 | Hard depth cap. Nodes deeper than this never render their children. Defaults to 50. |
maxBytes | number | 1048576 | Maximum serialized size before nothing is rendered. A payload over it shows only its size, a Copy button and a Download JSON button. Defaults to 1,048,576 (1 MB). |
parse | (raw: string) => unknown | Custom parser applied when value is a string. Receives the raw string
and must return a parsed value or throw. Defaults to JSON.parse. Use this
to support alternative serialization formats. | |
label | text | A heading drawn at the left of the header row, before the Fields / JSON switch, such as "Input" or "Output". It also names the card for assistive technology; without one the card is named "Payload". | |
labelCode | text | A name drawn a space after the label, set in code a weight lighter, such as an output's name:
with label "Output" and labelCode "notes" the header reads "Output notes", with no comma,
and the card is named "Output, notes". Ignored without a label. | |
view bindable | 'fields' | 'json' | 'fields' | Which view the payload shows. 'fields' lists each property with a
sentence-case label; 'json' shows the stored payload with its raw keys.
Bindable, and switched by the Fields / JSON control in the header row. |
bare | boolean | false | Draws the payload without its card, for a pane that already is one: no border, no divider under the header, and no count or Copy button, since the pane carries its own Copy. The Fields view is always one label and value per row with a quiet rule between rows, never the inline or grid layouts, so a person reads a record as a list. The Fields / JSON switch sits at the end of the header row, across from the label. |
plain | boolean | false | Shows a string value as it is, as text in a code block under the label, whatever it holds:
the Fields / JSON switch is not drawn, nothing is parsed and no invalid-JSON notice appears.
Use it for a value that is not JSON, or one too long to lay out as fields, and say so beside
it. A value that is not a string is shown as usual. |
linkFor | (field: PayloadInspectorField) => stringundefined | Returns the address a value in the Fields view leads to, so a value that
names something (a run, a workflow, a user) can link to it. Return
undefined to leave the value as text. The JSON view is never linked. | |
redact | string[] | Secret paths: values to hide in both views and in Copy, before anything is
laid out. Each path is dot-separated property names from the root, array
positions count from 1, and * stands for any one name or position (headers.authorization,
attachments.*.token). Read them from a JSON Schema with
readSecretPaths. When this is not passed, a property whose name reads as
a secret (token, key, password, authorization) is hidden as a fallback;
pass [] to hide nothing. | |
formatValue | (field: PayloadInspectorField) => stringundefined | Writes a value in the Fields view as the caller wants it, such as cents as
dollars. It receives the path and the stored value; return undefined to
keep the default. The JSON view and Copy always show the stored value. | |
jsonOnly | string[] | Top-level property names the Fields view leaves out and only the JSON view shows, such as a run's identifier or other internals. The Fields list ends with a muted "1 more in JSON" line so nothing hides silently, and the header counts every top-level field and says how many are JSON only ("3 fields, 1 in JSON only"). A name the value does not have is ignored, and so is the list for a value that is not an object. | |
fieldsValue | unknown | What the Fields view lays out and counts, when it is not value itself: a run's input
unwrapped from the envelope the engine stores it in, with the envelope's keys named in
jsonOnly. The JSON view, the size and Copy always show value, the payload as stored. | |
streaming | boolean | false | True while the payload is still arriving. value is the JSON text received
so far: fields appear as they complete, the last one shows "Receiving…", the
count reads "so far", and Copy waits until the stream ends. |
failed | boolean | false | True when the payload failed to load. The card keeps its header, hides the
switch, disables Copy, and shows failedMessage with a Try again button. |
failedMessage | text | 'Couldn't load the full result.' | What a failed load says. Defaults to "Couldn't load the full result." |
onRetry | () => void | Called when Try again is pressed after a failed load. Without it, no button is drawn. | |
emptyLabel | text | 'No payload' | The muted line shown when there is no payload. Defaults to "No payload". |
downloadFilename | text | 'payload.json' | The file name Download JSON saves a payload over maxBytes as. Defaults to "payload.json". |