Skip to content
tcpsystemsui

Theme

Colour scheme
Accent
Density
Radius
Esc

JsonViewer

Text-only <details> JSON tree: lazy children, paging, cycle and hostile-key safety, copy path and value, host edit actions.

beta

Examples

Api response

response { } 6 keys
id "req_9f3a21" string
status 200 number
model "gateway-large" string
usage { } 2 keys
lanes [ ] 2 items
cached false boolean
Api response.svelte
<script lang="ts">
	import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';
	const response = {
		id: 'req_9f3a21',
		status: 200,
		model: 'gateway-large',
		usage: { prompt_tokens: 1204, completion_tokens: 318 },
		lanes: ['primary', 'fallback'],
		cached: false
	};
</script>

<JsonViewer value={response} label="response" />

Open depth

config { } 3 keys
server { } 2 keys
port 8080 number
tls { } 2 keys
enabled true boolean
minVersion "1.3" string
database { } 3 keys
host "127.0.0.1" string
port 5000 number
pool { } 2 keys
min 2 number
max 20 number
features { } 2 keys
streaming true boolean
audit true boolean
Open depth.svelte
<script lang="ts">
	import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';
	const config = {
		server: { port: 8080, tls: { enabled: true, minVersion: '1.3' } },
		database: { host: '127.0.0.1', port: 5000, pool: { min: 2, max: 20 } },
		features: { streaming: true, audit: true }
	};
</script>

<JsonViewer value={config} label="config" openDepth={3} />

Paged array

events [ ] 25 items
0 { } 3 keys
1 { } 3 keys
2 { } 3 keys
3 { } 3 keys
4 { } 3 keys
Paged array.svelte
<script lang="ts">
	import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';
	const events = Array.from({ length: 25 }, (_, i) => ({ seq: i + 1, type: i % 5 === 0 ? 'deploy' : 'request', ok: i % 7 !== 0 }));
</script>

<JsonViewer value={events} label="events" pageSize={5} />

Edge cases

record { } 5 keys
name "gateway-vnext" string
note "A long description …t on the platform." string
empty { } object
none null null
self [Circular] circular
Edge cases.svelte
<script lang="ts">
	import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';
	const record: Record<string, unknown> = {
		name: 'gateway-vnext',
		note: 'A long description that explains in detail how this release changes request routing for every tenant on the platform.',
		empty: {},
		none: null
	};
	record.self = record;
</script>

<JsonViewer value={record} label="record" maxLength={40} openDepth={2} />

API

Import
import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';
PropTypeDefault
value?nativenone
label?native'root'
openDepth?native1
pageSize?native100
maxLength?native120
copyPathLabel?string'Copy path'
copyValueLabel?string'Copy value'
circularLabel?string'[Circular]'
unreadableLabel?string'[Unreadable]'
moreLabel?(remaining: number) => string(n: number) => `Show ${Math.min(n, pageSize)} more of ${n}`
actions?nativenone
track?nativenone
HookKind
.tcp-json-viewerRoot class
data-kindData attribute