use this code:
<div id="vueapp">
<textarea v-model="jsonstr" rows="8" cols="40"></textarea>
<pre>{{ jsonstr | pretty }}</pre>
</div>
and JS:
new Vue({
el: '#vueapp',
data: {
jsonstr: '{"id":1,"name":"A green door","price":12.50,"tags":["home","green"]}'
},
filters: {
pretty: function(value) {
return JSON.stringify(JSON.parse(value), null, 2);
}
}
})
Answer from Behnam on Stack OverflowGitHub
github.com › leezng › vue-json-pretty
GitHub - leezng/vue-json-pretty: A JSON tree view component that is easy to use and also supports data selection.
A Vue component for rendering JSON data as a tree structure.
Starred by 1.4K users
Forked by 141 users
Languages JavaScript 55.2% | TypeScript 26.3% | Vue 12.8% | Less 4.3% | HTML 1.4% | JavaScript 55.2% | TypeScript 26.3% | Vue 12.8% | Less 4.3% | HTML 1.4%
npm
npmjs.com › package › vue-json-pretty
vue-json-pretty - npm
October 28, 2025 - A JSON tree view component that is easy to use and also supports data selection.. Latest version: 2.6.0, last published: 4 months ago. Start using vue-json-pretty in your project by running `npm i vue-json-pretty`. There are 204 other projects ...
» npm install vue-json-pretty
Published Oct 28, 2025
Version 2.6.0
Author leezng
Repository https://github.com/leezng/vue-json-pretty
Leezng
leezng.github.io › vue-json-pretty
vue-json-pretty
Leezng (Daniel) · 博客 开源项目 关于我
GitHub
github.com › leezng › vue-json-pretty › releases
Releases · leezng/vue-json-pretty
A JSON tree view component that is easy to use and also supports data selection. - Releases · leezng/vue-json-pretty
Author leezng
SourceForge
sourceforge.net › projects › vue-json-pretty.mirror
Vue Json Pretty download | SourceForge.net
Download Vue Json Pretty for free. A JSON tree view component that is easy to use . A Vue component for rendering JSON data as a tree structure. The CSS file is included separately and needs to be imported manually.
jsDelivr
jsdelivr.com › package › npm › vue-json-pretty
vue-json-pretty CDN by jsDelivr - A CDN for npm and GitHub
October 28, 2025 - A free, fast, and reliable CDN for vue-json-pretty. A JSON tree view component that is easy to use and also supports data selection.
Published Oct 12, 2017
Repository https://github.com/leezng/vue-json-pretty
Top answer 1 of 7
49
use this code:
<div id="vueapp">
<textarea v-model="jsonstr" rows="8" cols="40"></textarea>
<pre>{{ jsonstr | pretty }}</pre>
</div>
and JS:
new Vue({
el: '#vueapp',
data: {
jsonstr: '{"id":1,"name":"A green door","price":12.50,"tags":["home","green"]}'
},
filters: {
pretty: function(value) {
return JSON.stringify(JSON.parse(value), null, 2);
}
}
})
2 of 7
36
HTML and JS have this built into the language. Try...
<pre>{{ yourObject }}</pre>
This gives the default indent, to specify a custom indent provide it as the third argument to JSON.stringify(...).
// replace 2 with '\t' to do tab indentation
<pre>{{ JSON.stringify(yourObject, null, 2) }}</pre>
If you're outside of Vue then using a combo of JSON.stringify and <pre> will work.
npm
npmjs.com › package › @hirect › vue-json-pretty
@hirect/vue-json-pretty - npm
March 25, 2022 - A JSON tree view component that is easy to use and also supports data selection.. Latest version: 1.0.0, last published: 4 years ago. Start using @hirect/vue-json-pretty in your project by running `npm i @hirect/vue-json-pretty`. There are no ...
» npm install @hirect/vue-json-pretty
Published Mar 25, 2022
Version 1.0.0
Author leezng
Repository https://github.com/leezng/vue-json-pretty
Vue Script
vuescript.com › home › other › pretty json data formatter for vue.js 2+
Pretty JSON Data Formatter For Vue.js 2+ - Vue Script
August 8, 2020 - Pretty JSON Data Formatter For Vue.js 2+ leezng Added 5 years ago · Live Demo Download Source Code · npm install vue-json-pretty · A vue.js 2+ project to beautify your JSON data with collapse, expand, and check support. 08/08/2020 · v1.6.7: Fix: Don’t introduce extra white in string value.
GitHub
github.com › leezng › vue-json-pretty › blob › dev › package.json
vue-json-pretty/package.json at dev · leezng/vue-json-pretty
A JSON tree view component that is easy to use and also supports data selection. - leezng/vue-json-pretty
Author leezng
Siongui
siongui.github.io › 2017 › 03 › 15 › vuejs-pretty-print-json-string
[Vue.js] Pretty Print JSON String - Theory and Practice
According to the answer in [2], the built-in JavaScript JSON.stringify method can help us pretty print the JSON string, so in the filter, JSON.parse the string first and then JSON.stringify it again. JavaScript: 'use strict'; new Vue({ el: '#vueapp', data: { jsonstr: '{"id":1,"name":"A green door","price":12.50,"tags":["home","green"]}' }, filters: { pretty: function(value) { return JSON.stringify(JSON.parse(value), null, 2); } } }) Tested on: Chromium Version 56.0.2924.76 Built on Ubuntu , running on Ubuntu 16.10 (64-bit) Vue.js 2.2.4 ·
GitHub
github.com › leezng › vue-json-pretty › issues
Issues · leezng/vue-json-pretty
A JSON tree view component that is easy to use and also supports data selection. - leezng/vue-json-pretty
Author leezng
Npm
npm.io › package › vue-json-pretty
Vue-json-pretty NPM | npm.io
<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>
Awesomeopensource
awesomeopensource.com › project › leezng › vue-json-pretty
Vue Json Pretty Alternatives
A JSON tree view component that is easy to use and also supports data selection. ... Prettier is an opinionated code formatter.