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

{
"ok":true,
"data":{
"id":"workspace_dom",
"status":"active",
"features":[...]3 items
}
}
Playground.vuevue
<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.

{
"ok":true,
"requestId":"req_dom_7d91",
"data":{
"project":{
"id":"proj_dom_studio",
"name":"DOM Studio",
"plan":"Team",
"features":[...]4 items
},
"usage":{
"components":68,
"blocks":73,
"lastPublishedAt":"2026-07-05T09:30:00.000Z"
}
},
"meta":{
"source":"api",
"durationMs":42,
"cache":{
"hit":false,
"ttl":60
}
}
}
<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

NameTypeTSDefaultDescription
valueanyanyA JSON-serializable value, or a raw JSON string when parseStrings is enabled.
titlestringstring''Optional label rendered in the viewer toolbar.
descriptionstringstring''Optional supporting text rendered below the title.
filenamestringstring''Optional filename shown in the toolbar and used by the source view.
mode'tree' | 'code'string'tree'Initial display mode.
showModeTogglebooleanbooleantrueShow the Tree / Code segmented control.
showToolbarbooleanbooleantrueRender the viewer toolbar.
copyablebooleanbooleantrueShow a copy button when the toolbar is visible.
parseStringsbooleanbooleantrueTreat string values as raw JSON source and format them when they parse.
indentnumbernumber2Spaces used when formatting JSON in code mode and clipboard output.
expandedDepthnumbernumber5Default branch depth to expand in tree mode. Use 0 to collapse everything.
previewLinesnumbernumber0Maximum visible lines before the viewer scrolls. Use 0 for no cap.
density'compact' | 'comfortable'string'comfortable'Tree row spacing.
framedbooleanbooleantrueRender the standard card frame around the viewer.
emptyTextstringstring'No JSON value.'Message shown when the supplied value is empty.

Auto-generated from JSON viewer.props and inline _edit hints.

Events

NamePayloadDescription
@update:mode'tree' | 'code'Fired when the built-in mode toggle changes the active view.
@copystringFired 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.