Command palette

@yasinsensoy/native

React Native · Components

JsonView

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

3 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

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/native";

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

Events

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

JSON text (invalid)

Import

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

JsonView

component

JSON viewer: shows data like API responses, config files or log entries as a colored, collapsible tree. The same core (@yasinsensoy/core/json-view) and the same features as JsonView on web.

  • Navigation: containers expand on press; expand/collapse all in the toolbar.
  • Search: searches keys and values ignoring Turkish letter case, expands and highlights the paths of matches automatically; the keyboard's "search" key and the arrows scroll to the next or previous result.
  • Copy: long-press a row → copy the value (formatted JSON) or the path (users[0].name). Since there is no hover on mobile, a long-press menu is used instead of web's row buttons.
  • Large data: only the expanded part is traversed; long arrays are split into chunks of 100, long strings are truncated, rows are drawn in a virtual list (only the visible ones).
  • Safe: Map, Set, Date, bigint, undefined and circular references are shown without errors. Colors come from the CodeBlock theme (ui.code).
  • On mobile long lines wrap instead of scrolling horizontally.
JsonView({ data, value, defaultExpanded, rootName, sortKeys, quoteKeys, collapseStringsAfter, groupArraysAfter, toolbar, search, copyable, linkify, onLinkPress, onSelect, maxHeight, label, style, testID, }: JsonViewProps): JSX.Element

Examples

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

Path segment: object key or array index.

type JsonPathSegment = string | number

JsonViewProps

interface

Props of the JsonView component (same names as on web).

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 cannot be parsed.
defaultExpanded?number | boolean2How many levels are expanded initially? true all, false only the root collapsed.
rootName?stringName of the root; prepended when copying a path (e.g. "response" → response.users[0]).
sortKeys?booleanfalseSort keys alphabetically?
quoteKeys?booleanfalseWrite keys with quotes ("name":)?
collapseStringsAfter?number120Strings longer than this are truncated and expand on press. 0 disables it.
groupArraysAfter?number100Arrays longer than this are split into [0 … 99] chunks.
toolbar?booleantrueThe toolbar on top (search, expand/collapse all, copy).
search?booleantrueSearch box in the toolbar.
copyable?booleantrueA "copy value" and "copy path" menu on long-pressing a row, and "copy all" in the toolbar.
linkify?booleantrueTurn strings starting with http(s):// into links?
onLinkPress?(url: string) => voidCalled when a link is pressed; if omitted the address opens in the system (Linking.openURL).
onSelect?(path: JsonPathSegment[], value: unknown) => voidCalled with the path and value when a key is pressed (e.g. to open a detail screen).
maxHeight?number | "none"448Maximum height of the visible area (pixels, scales with the device); when exceeded it scrolls and only visible rows are drawn. "none" is unlimited (the page's own scrolling is used then).
label?string"JSON"` (`messages.jsonView`)Screen reader name.
style?StyleProp<ViewStyle>Container style.
testID?stringTest id.