Command palette

@yasinsensoy/web

Web · Components

JsonView

JSON viewer: shows data such as API responses, config files and log entries as a colored, collapsible tree.

8 exports

Live example

Preview

{8 keys
id: 1042,
status: "active",
customer: {6 keys
name: "Ayşe Yılmaz",
vip: true,
puan: 4.8,
notlar: null
},
products: [2 items
],
tags: [2 items
0: "express-shipping",
1: "gift-package"
],
created: "2026-11-11T09:42:00.000Z",
description: "The customer asked for delivery after 18:00 on weekdays. The doorbell doesn't work, please call by phone. The package co",
measurements: [240 items
[0 … 99],
0: 0,
1: 12.5,
2: 24.7,
3: 36.6,
4: 47.9,
5: 58.5,
6: 68.2,
7: 76.8,
8: 84.1,
9: 90.2,
10: 94.9,
11: 98.1,
12: 99.7,
13: 99.9,
14: 98.4,
15: 95.4,
16: 90.9,
17: 85,
18: 77.8,
19: 69.4,
20: 59.8,
21: 49.4,
22: 38.2,
23: 26.3,
24: 14.1,
25: 1.7,
26: -10.8,
27: -23.1,
28: -35.1,
29: -46.5,
30: -57.2,
31: -66.9,
32: -75.7,
33: -83.2,
34: -89.5,
35: -94.4,
36: -97.8,
37: -99.6,
38: -99.9,
39: -98.7,
40: -95.9,
41: -91.6,
42: -85.9,
43: -78.8,
44: -70.6,
45: -61.2,
46: -50.8,
47: -39.7,
48: -27.9,
49: -15.8,
50: -3.3,
51: 9.2,
52: 21.5,
53: 33.5,
54: 45,
55: 55.8,
56: 65.7,
57: 74.6,
58: 82.3,
59: 88.7,
60: 93.8,
61: 97.4,
62: 99.5,
63: 100,
64: 98.9,
65: 96.3,
66: 92.3,
67: 86.7,
68: 79.8,
69: 71.7,
70: 62.5,
71: 52.2,
72: 41.2,
73: 29.5,
74: 17.4,
75: 5,
76: -7.5,
77: -19.9,
78: -32,
79: -43.5,
80: -54.4,
81: -64.4,
82: -73.5,
83: -81.4,
84: -88,
85: -93.2,
86: -97,
87: -99.3,
88: -100,
89: -99.2,
90: -96.8,
91: -92.9,
92: -87.5,
93: -80.8,
94: -72.9,
95: -63.8,
96: -53.7,
97: -42.7,
98: -31.1,
99: -19
]
}

Code

import { JsonView } from "@yasinsensoy/web";

<JsonView data={order} rootName="order" />

Events

  1. Events appear here when you interact with the preview.

JSON text (invalid)

Import

import { JsonView, kindOf, formatPath, toJsonText } from "@yasinsensoy/web";

JsonView

componentClient component

JSON viewer: shows data such as API responses, config files and log entries as a colored, collapsible tree.

  • Navigation: containers expand on click; expand/collapse all in the toolbar. Keyboard: ↑/↓ rows, → expands or enters, ← collapses or goes to the parent container, Enter toggles, Ctrl/⌘ + C copies the focused value.
  • Search: searches keys and values case-insensitively (Turkish-aware), expands the paths of matches automatically and highlights them; Enter goes to the next result.
  • Copying: copy a row's value (formatted JSON) or its path (users[0].name).
  • Large data: only the expanded part is traversed; long arrays are split into chunks of 100, long strings are truncated, and more than 400 rows are virtualized.
  • Safe: Map, Set, Date, bigint, undefined and circular references are shown without errors. Colors come from the CodeBlock theme.
JsonView({ data, value, defaultExpanded, rootName, sortKeys, quoteKeys, collapseStringsAfter, groupArraysAfter, toolbar, search, copyable, linkify, onSelect, maxHeight, label, className, classNames, }: JsonViewProps): JSX.Element

Examples

<JsonView data={response} rootName="response" defaultExpanded={1} />
<JsonView value={'{"name":"Jane","age":31}'} toolbar={false} />

kindOf

function

Type of a value.

kindOf(value: unknown, seen?: WeakSet<object>): JsonKind

formatPath

function

Converts a path to JavaScript access text: ["users", 0, "name"] → users[0].name. A root name, when given, is prepended.

formatPath(path: readonly JsonPathSegment[], root?: string): string

toJsonText

function

Converts a value to clipboard-friendly JSON text: Map becomes an object, Set an array, dates ISO strings, bigint numeric strings; circular references become "[Circular]".

toJsonText(value: unknown, space?: number): string

Classes that can be passed to the inner parts of JsonView.

NameTypeDescription
toolbar?stringTop toolbar.
viewport?stringScrolled area.
row?stringRow.

JsonViewProps

interface

Props of the JsonView component.

NameTypeDefaultDescription
data?unknownValue to show: an object, array or primitive. Map, Set, Date, bigint and circular references are shown safely too.
value?stringJSON text; given instead of data, an error is shown if it can't be parsed.
defaultExpanded?number | boolean2How many levels are initially expanded? true all, false only the root is collapsed.
rootName?stringName of the root; prepended when copying a path (e.g. "response" → response.users[0]).
sortKeys?booleanfalseSort keys alphabetically?
quoteKeys?booleanfalseWrite keys quoted ("name":)?
collapseStringsAfter?number120Strings longer than this are truncated and expand fully on click. 0 disables.
groupArraysAfter?number100Arrays longer than this are split into [0 … 99] chunks.
toolbar?booleantrueTop toolbar (search, expand/collapse all, copy).
search?booleantrueSearch box in the toolbar.
copyable?booleantrue"Copy value" and "copy path" buttons on rows.
linkify?booleantrueShould strings starting with http(s):// become links?
onSelect?(path: JsonPathSegment[], value: unknown) => voidCalled with the path and value when a key is clicked (e.g. to open a detail panel).
maxHeight?string"32rem"Maximum height of the visible area; it scrolls beyond that and more than 400 rows are virtualized. "none" is unlimited.
label?string"JSON"` (`messages.jsonView`)Screen reader name.
className?stringClasses added to the container.
classNames?JsonViewClassNamesClasses added to the inner parts.

Type of a value inside JsonView.

type JsonKind = "object" | "array" | "string" | "number" | "boolean" | "null" | "undefined" | "bigint" | "date" | "function" | "symbol" | "circular"

Path segment: object key or array index.

type JsonPathSegment = string | number