Component
JSON viewer
<DomJsonViewer>A read-only JSON viewer with a collapsible tree, formatted source view, syntax highlighting, and copy support.
Playground
Inspect a JSON value
JSON viewer playground
Pass a parsed value or raw JSON string, then choose between the collapsible tree and highlighted source view.
API response
<script setup>
import { reactive } from 'vue';
import { DomJsonViewer } from '@getdom/studio/vue';
const data = reactive({
"value": {
"ok": true,
"data": {
"id": "workspace_dom",
"status": "active",
"features": [
"docs",
"components",
"blocks"
]
}
},
"title": "API response",
"description": "",
"filename": "response.json",
"mode": "tree",
"showModeToggle": true,
"showToolbar": true,
"copyable": true,
"parseStrings": true,
"indent": 2,
"expandedDepth": 2,
"previewLines": 0,
"density": "comfortable",
"framed": true,
"emptyText": "No JSON value."
});
</script>
<template>
<DomJsonViewer
v-bind="data"
/>
</template>Demo
Collapsible API response
Tree mode keeps nested objects readable while preserving a code view for exact source output.
GET /api/projects/proj_dom_studio
Use tree mode to inspect nested data, or switch to highlighted source for copyable JSON.
<script setup>
import { DomJsonViewer } from '../../../lib/vue';
const response = {
ok: true,
requestId: 'req_dom_7d91',
data: {
project: {
id: 'proj_dom_studio',
name: 'DOM Studio',
plan: 'Team',
features: ['components', 'blocks', 'themes', 'agent context'],
},
usage: {
components: 68,
blocks: 73,
lastPublishedAt: '2026-07-05T09:30:00.000Z',
},
},
meta: {
source: 'api',
durationMs: 42,
cache: {
hit: false,
ttl: 60,
},
},
};
</script>
<template>
<div class="w-full max-w-3xl">
<DomJsonViewer
:value="response"
title="GET /api/projects/proj_dom_studio"
description="Use tree mode to inspect nested data, or switch to highlighted source for copyable JSON."
filename="project-response.json"
:expanded-depth="3"
/>
</div>
</template>
Demo
Raw JSON payload
Raw strings are parsed, formatted, syntax highlighted, and copied as normalized JSON.
Webhook payload
String values are parsed and reformatted before rendering.
{
"event": "checkout.completed",
"livemode": false,
"created": "2026-07-05T09:42:13.000Z",
"customer": {
"id": "cus_1842",
"email": "studio@example.com"
},
"items": [
{
"sku": "dom-source-access",
"quantity": 1,
"amount": 49900
}
],
"metadata": {
"workspace": "getdom.studio",
"source": "docs-demo"
}
}<script setup>
import { DomJsonViewer } from '../../../lib/vue';
const webhookPayload = `{
"event": "checkout.completed",
"livemode": false,
"created": "2026-07-05T09:42:13.000Z",
"customer": {
"id": "cus_1842",
"email": "studio@example.com"
},
"items": [
{
"sku": "dom-source-access",
"quantity": 1,
"amount": 49900
}
],
"metadata": {
"workspace": "getdom.studio",
"source": "docs-demo"
}
}`;
</script>
<template>
<div class="w-full max-w-3xl">
<DomJsonViewer
:value="webhookPayload"
title="Webhook payload"
description="String values are parsed and reformatted before rendering."
filename="checkout.completed.json"
mode="code"
:preview-lines="14"
/>
</div>
</template>
Reference
Props
Control props
| Name | Type | TS | Default | Description |
|---|---|---|---|---|
value | any | any | — | A JSON-serializable value, or a raw JSON string when parseStrings is enabled. |
title | string | string | '' | Optional label rendered in the viewer toolbar. |
description | string | string | '' | Optional supporting text rendered below the title. |
filename | string | string | '' | Optional filename shown in the toolbar and used by the source view. |
mode | 'tree' | 'code' | string | 'tree' | Initial display mode. |
showModeToggle | boolean | boolean | true | Show the Tree / Code segmented control. |
showToolbar | boolean | boolean | true | Render the viewer toolbar. |
copyable | boolean | boolean | true | Show a copy button when the toolbar is visible. |
parseStrings | boolean | boolean | true | Treat string values as raw JSON source and format them when they parse. |
indent | number | number | 2 | Spaces used when formatting JSON in code mode and clipboard output. |
expandedDepth | number | number | 5 | Default branch depth to expand in tree mode. Use 0 to collapse everything. |
previewLines | number | number | 0 | Maximum visible lines before the viewer scrolls. Use 0 for no cap. |
density | 'compact' | 'comfortable' | string | 'comfortable' | Tree row spacing. |
framed | boolean | boolean | true | Render the standard card frame around the viewer. |
emptyText | string | string | 'No JSON value.' | Message shown when the supplied value is empty. |
Auto-generated from JSON viewer.props and inline _edit hints.
Events
| Name | Payload | Description |
|---|---|---|
| @update:mode | 'tree' | 'code' | Fired when the built-in mode toggle changes the active view. |
| @copy | string | Fired after formatted JSON is copied to the clipboard. |
Names auto-detected from defineEmits and source emit() calls; payload and description from __doc.events when present.