leezng/vue-json-pretty

A JSON tree view component that is easy to use and also supports data selection.

JavaScript

1,471

325 commits

updated Jul 30, 2026

See the code

README

Vue Json Pretty

A Vue component for rendering JSON data as a tree structure.

Now it supports Vue3 at least. If you still use Vue2, see 1.x.

Build Status npm package GitHub license Sizes NPM downloads Issues

English | 简体中文

Features

  • As a JSON Formatter.
  • Written in TypeScript, support d.ts.
  • Support get item data from JSON.
  • Support big data.
  • Support editable.
  • Support search/filter with result navigation.

Environment Support

  • Modern browsers, Electron and Internet Explorer 11 (with polyfills)
  • Server-side Rendering
IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edgelast 10 versionslast 10 versionslast 10 versionslast 2 versions

Using NPM or Yarn

$ npm install vue-json-pretty --save
$ yarn add vue-json-pretty

Use Vue2

$ npm install vue-json-pretty@v1-latest --save

Usage

The CSS file is included separately and needs to be imported manually. You can either import CSS globally in your app (if supported by your framework) or directly from the component.

<template>
  <div>
    <vue-json-pretty :data="{ key: 'value' }" />
  </div>
</template>

<script>
import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';

export default {
  components: {
    VueJsonPretty,
  },
};
</script>

Use Nuxt.js

  1. In plugins/vue-json-pretty.js
import Vue from 'vue'
import VueJsonPretty from 'vue-json-pretty'

Vue.component("vue-json-pretty", VueJsonPretty)
  1. In nuxt.config.js
css: [
  'vue-json-pretty/lib/styles.css'
],
plugins: [
  '@/plugins/vue-json-pretty'
],

Props

PropertyDescriptionTypeDefault
data(v-model)JSON data, support v-model when use editableJSON object-
indentJSON indentnumber2
collapsedNodeLengthObjects or arrays which length is greater than this threshold will be collapsednumber-
deepPaths greater than this depth will be collapsednumber-
showLengthShow the length when collapsedbooleanfalse
showLineShow the linebooleantrue
showLineNumberShow the line numberbooleanfalse
showIconShow the iconbooleanfalse
showDoubleQuotesShow doublequotes on keybooleantrue
virtualUse virtual scrollbooleanfalse
heightThe height of list when using virtualnumber400
itemHeightFixed row height when using virtual (Estimated row height used before measurement when dynamicHeight is true)number20
dynamicHeightEnable dynamic row heights (measured per row)booleantrue
selectedValue(v-model)Selected data pathstring, array-
rootPathRoot data pathstringroot
nodeSelectableDefines whether a node supports selection(node) => boolean-
selectableTypeSupport path select, default nonemultiple | single-
showSelectControllerShow the select controllerbooleanfalse
selectOnClickNodeTrigger select when click nodebooleantrue
highlightSelectedNodeSupport highlighting selected nodesbooleantrue
collapsedOnClickBracketsSupport click brackets to collapsebooleantrue
renderNodeKeyrender node key, or use slot #renderNodeKey({ node, defaultKey }) => vNode-
renderNodeValuerender node value, or use slot #renderNodeValue({ node, defaultValue }) => vNode-
renderNodeActionsrender node actions, or use slot #renderNodeActionsboolean | ({ node, defaultActions }) => vNodefalse
editableSupport editablebooleanfalse
editableTriggerTriggerclick | dblclickclick
themeSets the theme of the component. Options are 'light' or 'dark', with dark mode enhancing visibility on dark backgrounds'light' | 'dark'light
searchKeyword for filtering the JSON tree. When non-empty, only matching nodes and their ancestors are shownstring-
searchCaseSensitiveWhether the search is case-sensitivebooleanfalse
searchStrictWhether to use strict (exact) matching. When false, uses fuzzy (includes) matchingbooleanfalse
searchModeSearch scope: 'key' for property names, 'value' for values, 'all' for both'key' | 'value' | 'all''all'

Events

Event NameDescriptionParameters
nodeClicktriggers when click node(node: NodeData)
nodeMouseovertriggers when mouseover node(node: NodeData)
bracketsClicktriggers when click brackets(collapsed: boolean, node: NodeData)
iconClicktriggers when click icon(collapsed: boolean, node: NodeData)
selectedChangetriggers when the selected value changed(newVal, oldVal)
searchMatchChangetriggers when search results change or navigation occurs({ currentIndex, totalCount })

Slots

Slot NameDescriptionParameters
renderNodeKeyrender node key{ node, defaultKey }
renderNodeValuerender node value{ node, defaultValue }
renderNodeActionsrender node actionsboolean | ({ node, defaultActions }) => vNodefalse

Expose (via template ref)

MethodDescriptionReturns
nextMatch()Navigate to the next search match-
prevMatch()Navigate to the previous search match-
getSearchResultInfo()Get current search result info{ currentIndex, totalCount }

Contributors

format
json
json-tree
pretty
tree
vue
vue3
vue-component

leezng/vue-json-pretty

A JSON tree view component that is easy to use and also supports data selection.

JavaScript

1,471

325 commits

updated Jul 30, 2026

See the code

README

Vue Json Pretty

A Vue component for rendering JSON data as a tree structure.

Now it supports Vue3 at least. If you still use Vue2, see 1.x.

Build Status npm package GitHub license Sizes NPM downloads Issues

English | 简体中文

Features

  • As a JSON Formatter.
  • Written in TypeScript, support d.ts.
  • Support get item data from JSON.
  • Support big data.
  • Support editable.
  • Support search/filter with result navigation.

Environment Support

  • Modern browsers, Electron and Internet Explorer 11 (with polyfills)
  • Server-side Rendering
IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edgelast 10 versionslast 10 versionslast 10 versionslast 2 versions

Using NPM or Yarn

$ npm install vue-json-pretty --save
$ yarn add vue-json-pretty

Use Vue2

$ npm install vue-json-pretty@v1-latest --save

Usage

The CSS file is included separately and needs to be imported manually. You can either import CSS globally in your app (if supported by your framework) or directly from the component.

<template>
  <div>
    <vue-json-pretty :data="{ key: 'value' }" />
  </div>
</template>

<script>
import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';

export default {
  components: {
    VueJsonPretty,
  },
};
</script>

Use Nuxt.js

  1. In plugins/vue-json-pretty.js
import Vue from 'vue'
import VueJsonPretty from 'vue-json-pretty'

Vue.component("vue-json-pretty", VueJsonPretty)
  1. In nuxt.config.js
css: [
  'vue-json-pretty/lib/styles.css'
],
plugins: [
  '@/plugins/vue-json-pretty'
],

Props

PropertyDescriptionTypeDefault
data(v-model)JSON data, support v-model when use editableJSON object-
indentJSON indentnumber2
collapsedNodeLengthObjects or arrays which length is greater than this threshold will be collapsednumber-
deepPaths greater than this depth will be collapsednumber-
showLengthShow the length when collapsedbooleanfalse
showLineShow the linebooleantrue
showLineNumberShow the line numberbooleanfalse
showIconShow the iconbooleanfalse
showDoubleQuotesShow doublequotes on keybooleantrue
virtualUse virtual scrollbooleanfalse
heightThe height of list when using virtualnumber400
itemHeightFixed row height when using virtual (Estimated row height used before measurement when dynamicHeight is true)number20
dynamicHeightEnable dynamic row heights (measured per row)booleantrue
selectedValue(v-model)Selected data pathstring, array-
rootPathRoot data pathstringroot
nodeSelectableDefines whether a node supports selection(node) => boolean-
selectableTypeSupport path select, default nonemultiple | single-
showSelectControllerShow the select controllerbooleanfalse
selectOnClickNodeTrigger select when click nodebooleantrue
highlightSelectedNodeSupport highlighting selected nodesbooleantrue
collapsedOnClickBracketsSupport click brackets to collapsebooleantrue
renderNodeKeyrender node key, or use slot #renderNodeKey({ node, defaultKey }) => vNode-
renderNodeValuerender node value, or use slot #renderNodeValue({ node, defaultValue }) => vNode-
renderNodeActionsrender node actions, or use slot #renderNodeActionsboolean | ({ node, defaultActions }) => vNodefalse
editableSupport editablebooleanfalse
editableTriggerTriggerclick | dblclickclick
themeSets the theme of the component. Options are 'light' or 'dark', with dark mode enhancing visibility on dark backgrounds'light' | 'dark'light
searchKeyword for filtering the JSON tree. When non-empty, only matching nodes and their ancestors are shownstring-
searchCaseSensitiveWhether the search is case-sensitivebooleanfalse
searchStrictWhether to use strict (exact) matching. When false, uses fuzzy (includes) matchingbooleanfalse
searchModeSearch scope: 'key' for property names, 'value' for values, 'all' for both'key' | 'value' | 'all''all'

Events

Event NameDescriptionParameters
nodeClicktriggers when click node(node: NodeData)
nodeMouseovertriggers when mouseover node(node: NodeData)
bracketsClicktriggers when click brackets(collapsed: boolean, node: NodeData)
iconClicktriggers when click icon(collapsed: boolean, node: NodeData)
selectedChangetriggers when the selected value changed(newVal, oldVal)
searchMatchChangetriggers when search results change or navigation occurs({ currentIndex, totalCount })

Slots

Slot NameDescriptionParameters
renderNodeKeyrender node key{ node, defaultKey }
renderNodeValuerender node value{ node, defaultValue }
renderNodeActionsrender node actionsboolean | ({ node, defaultActions }) => vNodefalse

Expose (via template ref)

MethodDescriptionReturns
nextMatch()Navigate to the next search match-
prevMatch()Navigate to the previous search match-
getSearchResultInfo()Get current search result info{ currentIndex, totalCount }

Contributors

format
json
json-tree
pretty
tree
vue
vue3
vue-component

Project health

Overall

4.6/10

Maintained

5/10

Code review

7/10
OpenSSF Scorecard

Latest release

2.6.0 · Oct 28, 2025

Releases this year

1

Significant stargazers

XenoAmess

164 followers · starred Jan 2026

Michael Angelo Rivera

37 followers · starred May 2024

Emma Zühlcke

39 followers · starred Jan 2019

沈青川

827 followers · starred May 2025