JSONViewer
Validates and deterministically formats JSON into a searchable, copyable, virtualized line view.@gemologic/sheen-code · contentPlayground
This example has no scalar controls. Its validated source remains interactive below.
<JSONViewer value={response} label="API response" />Variant matrix
API responseAPI response9 of 9 lines
Anatomy
- Package
@gemologic/sheen-code- Source
packages/code/src/JSONViewer.tsx- Tokens
--sheen-color-bg-raised--sheen-color-warning-subtle--sheen-font-mono
Accessibility
Role: named region containing a focusable virtual list and listitemsKeyboard: Tab, Shift+Tab, Enter, Space, PageUp, PageDown, Home, EndDo
- Pass parsed application data and let JSONViewer validate it.
- Keep sortKeys enabled for copyable diagnostics.
Do not
- Do not pass secrets or authorization material.
- Do not pass class instances and assume private properties are hidden.
Generated props
| Name | Type | Default | Description |
|---|---|---|---|
value * | unknown | — | JSON-compatible value; functions, symbols, bigint, nonfinite numbers, cycles, and excessive depth are rejected. |
label * | string | — | Required accessible viewer and line-list name. |
indent | 2 | 4 | 2 | Pretty-print indentation. |
sortKeys | boolean | true | Sorts object keys for deterministic output. |
maxDepth | number | 32 | Maximum accepted nesting depth from 1 to 64. |
searchable | boolean | true | Shows a debounced search over formatted lines. |
copyable | boolean | true | Copies the complete validated JSON string. |
initialHeight | number | 360 | Deterministic SSR and initial viewport height in pixels from 120 to 1200. |
lineHeight | number | 22 | Fixed virtual row height in pixels from 16 to 48. |
onCopyError | (error: unknown) => void | — | Receives Clipboard API failures without exposing raw errors in the UI. |