Overview
Reference usage
Compact inspector for structured payloads. Presents a payload as an interactive JSON tree with a visible label, byte size, truncation state, and a single copy action.
Overview
PayloadInspector wraps JsonViewer, Badge, and CopyButton into a single component optimized for operational dashboards — workflow engines, API consoles, webhook debuggers, and background job UIs. Pass any JSON-serializable value; the inspector handles parsing, copy affordances, and edge cases.
Edge cases handled out of the box:
null,boolean,number, and plain strings — shown inline as primitives- Arrays and objects — navigable in the JSON tree
- Invalid JSON strings — shown with a parse error notice above the raw text
- Empty / no payload — shows a "No payload" placeholder
- Oversized payloads — JsonViewer's built-in cap prevents browser freezes
- Truncated payloads — a header badge indicates producer-side truncation
- Circular references and non-serializable values (e.g. BigInt) — an explanatory message renders instead of the tree; size reads "Unknown size"
Usage
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 header copy button 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 actually passed as value. It is hidden for empty and unserializable payloads.
Redacting sensitive fields
Redact the payload before passing it as value — the inspector renders exactly what it receives:
Custom parser for non-JSON formats
Pass a parse function to support alternative serialization formats:
Accessibility
The root element is a plain <div> — not a landmark — so a dashboard rendering many inspectors adds nothing to the screen reader's landmark list. The visible label names the panel, and the JSON tree is cinder's JsonViewer, a WAI-ARIA tree composite; see json-viewer accessibility documentation for its keyboard contract.
Parse errors render with role="alert" for immediate announcement. Empty states use role="status". The byte size span carries an aria-label like "13 B payload size" for screen readers that skip the visual context. See payload-inspector.a11y.md for the full pattern.
- userId: "u_8f2a3b"
- action: "checkout"
- timestamp: "2026-06-11T14:22:00Z"
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.
- 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 null, invalid JSON, and empty payload states in the inspector.
Signal payload
Inspect a workflow signal payload — a common pattern in activity result dashboards.
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. Pass
undefined when no payload is available yet. | |
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 for the JSON tree. Nodes deeper than this start collapsed. Defaults to 1. |
maxDepth | number | 50 | Hard depth cap for the JSON tree. Nodes deeper than this never render their children. Defaults to 50. |
maxBytes | number | 1048576 | Maximum byte size before the tree view is replaced with an oversize placeholder. 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 | 'Payload inspector' | Visible header label for the inspector. Defaults to "Payload inspector". |