{"id":6350,"date":"2024-01-11T16:40:00","date_gmt":"2024-01-11T16:40:00","guid":{"rendered":"https:\/\/codehim.com\/?p=6350"},"modified":"2024-01-22T14:44:17","modified_gmt":"2024-01-22T09:44:17","slug":"javascript-json-formatter-with-tree-view","status":"publish","type":"post","link":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/","title":{"rendered":"JavaScript JSON Formatter with Tree View"},"content":{"rendered":"<p>This JavaScript code snippet helps you to create JSON formatter with a tree view. It uses <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/JSON\/stringify\" target=\"_blank\" rel=\"noopener\">JSON.stringify() method<\/a> to convert a JavaScript object or value to a JSON string. You can input JSON data and view it in the well-formatted collapsible tree view.<\/p>\n<p>Besides this, the interface comes with all necessary controls to load JSON data, expand, and reset input fields. The textarea, buttons, and other layouts of this tool can be customized with additional CSS according to your needs.<\/p>\n<h2>How to Create JavaScript JSON Formatter with Tree View<\/h2>\n<p>1. First of all, create the HTML structure as follows:<\/p>\n<pre class=\"prettyprint linenums lang-html\">&lt;div class=\"container\"&gt;\r\n    &lt;div id=\"first\"&gt;\r\n      &lt;form class=\"form\"&gt;\r\n        &lt;label class=\"form__label--hidden\" for=\"msg\"&gt;Input json:&lt;\/label&gt;\r\n        &lt;textarea class=\"form__input\" class=\"form__input\" id=\"msg\" placeholder=\"Input json...\" rows=\"6\"&gt;&lt;\/textarea&gt;\r\n      &lt;\/form&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div id=\"two\"&gt;\r\n      &lt;button type=\"button\" class=\"load-json\"&gt;Load&lt;\/button&gt;      \r\n      &lt;button type=\"button\" class=\"collapse\"&gt;Collapse&lt;\/button&gt;\r\n      &lt;button type=\"button\" class=\"expand\"&gt;Expand&lt;\/button&gt;\r\n      &lt;button type=\"button\" class=\"reset\"&gt;Reset&lt;\/button&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div id=\"three\"&gt;\r\n      &lt;div id=\"json\"&gt;&lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n  &lt;\/div&gt;  \r\n<\/pre>\n<p>2. After that, add the following CSS styles to your project:<\/p>\n<pre class=\"prettyprint linenums lang-css\">input, textarea {\r\n  display: block;\r\n  outline: 0;\r\n  border: 0;\r\n}\r\ninput:focus, textarea:focus {\r\n  transition: 0.2s;\r\n}\r\nbody {\r\n  background-color: #fff;\r\n  font-family: 'Open Sans', Helvetica, sans-serif;\r\n}\r\n.container {\r\n  width: 100%;\r\n  margin: 30px auto;\r\n}\r\n#first {\r\n  width: 350px;\r\n  float: left;\r\n  margin-left: 2%;\r\n  margin-right: 2%;\r\n}\r\n#two {\r\n  width: 100px;\r\n  float: left;\r\n  margin-right: 2%;\r\n  margin-left: 2%;\r\n  padding-top: 15%;\r\n}\r\n#three {\r\n  width: 680px;\r\n  float: left;\r\n  margin-left: 1%;\r\n   margin-top: -12px; \r\n}\r\n.form__label {\r\n  display: block;\r\n  margin-bottom: 0.625em;\r\n}\r\n.form__label--hidden {\r\n  border: 0;\r\n  clip: rect(0 0 0 0);\r\n  height: 1px;\r\n  margin: -1px;\r\n  overflow: hidden;\r\n  padding: 0;\r\n  position: absolute;\r\n  width: 1px;\r\n}\r\n.form__input {\r\n  width: 100%;\r\n   height: 560px; \r\n  font-size: 1em;\r\n  padding: 0.83333em;\r\n  margin-bottom: 5px;\r\n  border: 6px solid #05bcaf;\r\n  border-radius: 0.4em;\r\n  background: #ebecec;\r\n  color: #656D78;\r\n  font-weight: 300;\r\n}\r\n.form__modal {\r\n  width: 83%;\r\n  font-size: 1em;\r\n  padding: 0.83333em;\r\n  margin-bottom: 5px;\r\n  border-bottom: 6px solid #05bcaf;\r\n  border-radius: 0.4em;\r\n  background: #ebecec;\r\n  color: #656D78;\r\n  font-weight: 300;\r\n}\r\n\r\n.load-json, .reset, .collapse, .expand, [type^=\"button\"] {\r\n  padding: 0.9375em 1.875em;\r\n  border: 0;\r\n  border-radius: 0.4em;\r\n  color: #fff;\r\n  text-transform: uppercase;\r\n  font-size: 0.875em;\r\n  font-weight: 400;\r\n  transition: opacity 0.2s;\r\n  display: block;\r\n  width: 100%;\r\n}\r\n.load-json:hover, .reset:hover, .collapse:hover, .expand:hover, [type^=\"button\"]:hover {\r\n  opacity: 0.75;\r\n  cursor: pointer;\r\n}\r\n.load-json {\r\n  background-color:  #3BAFDA;\r\n}\r\n.reset {\r\n  background-color: #e87376;\r\n}\r\n.collapse {\r\n  background-color: #D770AD;\r\n}\r\n.expand {\r\n  background-color: #F6BB42;\r\n}\r\n[type^=\"button\"] {\r\n   margin-bottom: 1.42857em; \r\n  width: 120px;\r\n  margin-right: 0.625em;\r\n  outline:none;\r\n}\r\n.json-viewer {\r\n  display: inline-block;\r\n  overflow: scroll;\r\n  height:  563px;\r\n  width: 600px;\r\n\tcolor: #656D78;\r\n  padding: 10px 10px 10px 20px;\r\n  background-color: #ebecec;\r\n  border: 6px solid #05bcaf;\r\n  border-radius: 0.4em;\r\n  margin-bottom: 3px;\r\n}\r\n\r\n.json-viewer ul {\r\n\tlist-style-type: none;\r\n\tmargin: 0;\r\n\tmargin: 0 0 0 1px;\r\n\tborder-left: 3px dotted #ccc;\r\n\tpadding-left: 2em;\r\n}\r\n\r\n.json-viewer .hide {\r\n\tdisplay: none;\r\n}\r\n\r\n.json-viewer ul li .type-string,\r\n.json-viewer ul li .type-date {\r\n\tcolor:  #05bcaf;\r\n}\r\n\r\n.json-viewer ul li .type-boolean {\r\n\tcolor: #F6BB42;\r\n\tfont-weight: bold;\r\n}\r\n\r\n.json-viewer ul li .type-number {\r\n\tcolor:   #e87376;\r\n}\r\n\r\n.json-viewer ul li .type-null {\r\n\tcolor: #EC87C0;\r\n}\r\n\r\n.json-viewer a.list-link {\r\n\tcolor: #656D78;\r\n\ttext-decoration: none;\r\n\tposition: relative;\r\n}\r\n\r\n.json-viewer a.list-link:before {\r\n\tcolor: #aaa;\r\n\tcontent: \"\\25BC\";\r\n\tposition: absolute;\r\n\tdisplay: inline-block;\r\n\twidth: 1em;\r\n\tleft: -1em;\r\n}\r\n\r\n.json-viewer a.list-link.collapsed:before {\r\n\tcontent: \"\\25B6\";\r\n}\r\n\r\n.json-viewer a.list-link.empty:before {\r\n\tcontent: \"\";\r\n}\r\n\r\n.json-viewer .items-ph {\r\n\tcolor: #aaa;\r\n\tpadding: 0 1em;\r\n}\r\n\r\n.json-viewer .items-ph:hover {\r\n\ttext-decoration: underline;\r\n}<\/pre>\n<p>3. Finally, add the following JavaScript code and done.<\/p>\n<pre class=\"prettyprint linenums lang-js\">var jsonObj = {};\r\nvar jsonViewer = new JSONViewer();\r\ndocument.querySelector(\"#json\").appendChild(jsonViewer.getContainer());\r\n\r\nvar textarea = document.querySelector(\"textarea\");\r\ntextarea.value = JSON.stringify([\r\n  {\r\n    \"id\": \"001\",\r\n    \"user\": \"megan_F0x\",\r\n    \"profile\":\r\n      {    \r\n          \"nama\":\"Megan Fox\",\r\n          \"alamat\":\"Jl Nin aja dulu\",\r\n          \"telepon\":628123456789,\r\n          \"email\":\"duh@malu.co\",\r\n          \"social media\": \r\n            {\r\n              \"facebook\":\"megan fox\",\r\n              \"twitter\":\"@megan_F0x\"\r\n            }\r\n      },\r\n    \"pengalaman\":[\r\n            {\r\n              \"perusahaan\":\"PT Transformer\",\r\n              \"daritahun\": 2010,\r\n              \"sampaitahun\": 2011,\r\n              \"posisi\": \"junior developer\",\r\n              \"promosi karir\": null,\r\n              \"listpekerjaan\": [\r\n                {\r\n                  \"jenis\": \"project base\",\r\n                  \"deskripsi\": \"front end developer\",\r\n                  \"lamapekerjaan\": \"6 bulan\",\r\n                  \"deadline bonus\": true,\r\n                  \"rekan kerja\": [\r\n                    {\r\n                      \"nama\": \"shia lebaouf\",\r\n                      \"posisi\": \"lead developer\",\r\n                      \"contact\": \r\n                        {\r\n                          \"telepon\" : 628890066631,\r\n                          \"email\": \"shia@lebaouf.com\",\r\n                          \"socialmedia\": {\r\n                            \"facebook\": \"shia lebaouf\",\r\n                            \"twitter\": \"@shia lebaouf\"\r\n                          }\r\n                        }\r\n                    },\r\n                    {\r\n                      \"nama\": \"josh duhamel\",\r\n                      \"posisi\": \"senior developer\",\r\n                      \"contact\": \r\n                        {\r\n                          \"telepon\" : 62345667687788,\r\n                          \"email\": \"josh@duhamel.com\",\r\n                          \"socialmedia\": {\r\n                            \"facebook\": \"josh duhamel\",\r\n                            \"twitter\": \"@josh duhamel\"\r\n                          }\r\n                        }\r\n                    }]\r\n                },\r\n                {\r\n                  \"jenis\": \"project base\",\r\n                  \"jabatan\": \"web developer\",\r\n                  \"lamapekerjaan\": \"3 bulan\",\r\n                  \"deadline bonus\": false,\r\n                  \"rekan kerja\": [\r\n                    {\r\n                      \"nama\": \"stephen amell\",\r\n                      \"posisi\": \"lead developer\",\r\n                      \"contact\": \r\n                        {\r\n                          \"telepon\" : 629485765690,\r\n                          \"email\": \"stephen@amell.com\",\r\n                          \"socialmedia\": {\r\n                            \"facebook\": \"stephen amell\",\r\n                            \"twitter\": \"@stephen_amell\"\r\n                          }\r\n                        }\r\n                    },\r\n                    {\r\n                      \"nama\": \"tyler perry\",\r\n                      \"posisi\": \"senior developer\",\r\n                      \"contact\": \r\n                        {\r\n                          \"telepon\" : 62948453666,\r\n                          \"email\": \"tyler@perry.com\",\r\n                          \"socialmedia\": {\r\n                            \"facebook\": \"tyler perry\",\r\n                            \"twitter\": \"@tyler perry\"\r\n                          }\r\n                        }\r\n                    }]\r\n                }]\r\n            }]\r\n  }\r\n]);\r\n\r\n\/\/ textarea value to JSON object\r\nvar setJSON = function () {\r\n  try {\r\n    var value = textarea.value;\r\n    jsonObj = JSON.parse(value);\r\n  }\r\n  catch (err) {\r\n    alert(err);\r\n  }\r\n};\r\n\r\n\/\/ load default value\r\nsetJSON();\r\n\r\nvar loadJsonBtn = document.querySelector(\"button.load-json\");\r\nvar collapseBtn = document.querySelector(\"button.collapse\");\r\nvar expandBtn = document.querySelector(\"button.expand\");\r\nvar resetBtn = document.querySelector(\"button.reset\");\r\n\r\nloadJsonBtn.addEventListener(\"click\", function () {\r\n  setJSON();\r\n  jsonViewer.showJSON(jsonObj);\r\n});\r\n\r\ncollapseBtn.addEventListener(\"click\", function () {\r\n  jsonViewer.showJSON(jsonObj, null, 1);\r\n});\r\n\r\nexpandBtn.addEventListener(\"click\", function () {\r\n  setJSON();\r\n  jsonViewer.showJSON(jsonObj);\r\n});\r\n\r\nresetBtn.addEventListener(\"click\", function () {\r\n  document.getElementById(\"msg\").value = \"\";\r\n});<\/pre>\n<p>That&#8217;s all! hopefully, you have successfully integrated this JSON Formatter code snippet into your project. If you have any questions or facing any issues, feel free to comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This JavaScript code snippet helps you to create JSON formatter with a tree view. It uses JSON.stringify() method to convert&#8230;<\/p>\n","protected":false},"author":1,"featured_media":6385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[116],"tags":[],"class_list":["post-6350","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vanilla-javascript"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript JSON Formatter with Tree View &#8212; CodeHim<\/title>\n<meta name=\"description\" content=\"Here is a lightweight JavaScript code snippet to create JSON formatter tree view. You can view demo and download source code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript JSON Formatter with Tree View &#8212; CodeHim\" \/>\n<meta property=\"og:description\" content=\"Here is a lightweight JavaScript code snippet to create JSON formatter tree view. You can view demo and download source code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/\" \/>\n<meta property=\"og:site_name\" content=\"CodeHim\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codehimofficial\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-11T16:40:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-22T09:44:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"960\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Asif Mughal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:site\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Asif Mughal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/\"},\"author\":{\"name\":\"Asif Mughal\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\"},\"headline\":\"JavaScript JSON Formatter with Tree View\",\"datePublished\":\"2024-01-11T16:40:00+00:00\",\"dateModified\":\"2024-01-22T09:44:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/\"},\"wordCount\":153,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png\",\"articleSection\":[\"Vanilla JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/\",\"url\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/\",\"name\":\"JavaScript JSON Formatter with Tree View &#8212; CodeHim\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png\",\"datePublished\":\"2024-01-11T16:40:00+00:00\",\"dateModified\":\"2024-01-22T09:44:17+00:00\",\"description\":\"Here is a lightweight JavaScript code snippet to create JSON formatter tree view. You can view demo and download source code.\",\"breadcrumb\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#primaryimage\",\"url\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png\",\"contentUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png\",\"width\":1280,\"height\":960,\"caption\":\"JavaScript JSON Formatter with Tree View\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codehim.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Vanilla JavaScript\",\"item\":\"https:\/\/codehim.com\/category\/vanilla-javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript JSON Formatter with Tree View\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codehim.com\/#website\",\"url\":\"https:\/\/codehim.com\/\",\"name\":\"CodeHim\",\"description\":\"Web Design Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"alternateName\":\"Web Design Codes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codehim.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/codehim.com\/#organization\",\"name\":\"CodeHim - Web Design Code & Scripts\",\"url\":\"https:\/\/codehim.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"contentUrl\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"width\":280,\"height\":280,\"caption\":\"CodeHim - Web Design Code & Scripts\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/codehimofficial\",\"https:\/\/x.com\/CodeHimOfficial\",\"https:\/\/www.instagram.com\/codehim\/\",\"https:\/\/www.linkedin.com\/company\/codehim\",\"https:\/\/co.pinterest.com\/codehim\/\",\"https:\/\/www.youtube.com\/@codehim\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\",\"name\":\"Asif Mughal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"caption\":\"Asif Mughal\"},\"description\":\"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.\",\"sameAs\":[\"https:\/\/codehim.com\"],\"url\":\"https:\/\/codehim.com\/author\/asif-mughal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript JSON Formatter with Tree View &#8212; CodeHim","description":"Here is a lightweight JavaScript code snippet to create JSON formatter tree view. You can view demo and download source code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript JSON Formatter with Tree View &#8212; CodeHim","og_description":"Here is a lightweight JavaScript code snippet to create JSON formatter tree view. You can view demo and download source code.","og_url":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/","og_site_name":"CodeHim","article_publisher":"https:\/\/www.facebook.com\/codehimofficial","article_published_time":"2024-01-11T16:40:00+00:00","article_modified_time":"2024-01-22T09:44:17+00:00","og_image":[{"width":1280,"height":960,"url":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png","type":"image\/png"}],"author":"Asif Mughal","twitter_card":"summary_large_image","twitter_creator":"@CodeHimOfficial","twitter_site":"@CodeHimOfficial","twitter_misc":{"Written by":"Asif Mughal","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#article","isPartOf":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/"},"author":{"name":"Asif Mughal","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed"},"headline":"JavaScript JSON Formatter with Tree View","datePublished":"2024-01-11T16:40:00+00:00","dateModified":"2024-01-22T09:44:17+00:00","mainEntityOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/"},"wordCount":153,"commentCount":0,"publisher":{"@id":"https:\/\/codehim.com\/#organization"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png","articleSection":["Vanilla JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/","url":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/","name":"JavaScript JSON Formatter with Tree View &#8212; CodeHim","isPartOf":{"@id":"https:\/\/codehim.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#primaryimage"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png","datePublished":"2024-01-11T16:40:00+00:00","dateModified":"2024-01-22T09:44:17+00:00","description":"Here is a lightweight JavaScript code snippet to create JSON formatter tree view. You can view demo and download source code.","breadcrumb":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#primaryimage","url":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png","contentUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/04\/www.codehim-7.png","width":1280,"height":960,"caption":"JavaScript JSON Formatter with Tree View"},{"@type":"BreadcrumbList","@id":"https:\/\/codehim.com\/vanilla-javascript\/javascript-json-formatter-with-tree-view\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codehim.com\/"},{"@type":"ListItem","position":2,"name":"Vanilla JavaScript","item":"https:\/\/codehim.com\/category\/vanilla-javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript JSON Formatter with Tree View"}]},{"@type":"WebSite","@id":"https:\/\/codehim.com\/#website","url":"https:\/\/codehim.com\/","name":"CodeHim","description":"Web Design Code Snippets","publisher":{"@id":"https:\/\/codehim.com\/#organization"},"alternateName":"Web Design Codes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codehim.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codehim.com\/#organization","name":"CodeHim - Web Design Code & Scripts","url":"https:\/\/codehim.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/","url":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","contentUrl":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","width":280,"height":280,"caption":"CodeHim - Web Design Code & Scripts"},"image":{"@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codehimofficial","https:\/\/x.com\/CodeHimOfficial","https:\/\/www.instagram.com\/codehim\/","https:\/\/www.linkedin.com\/company\/codehim","https:\/\/co.pinterest.com\/codehim\/","https:\/\/www.youtube.com\/@codehim"]},{"@type":"Person","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed","name":"Asif Mughal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","caption":"Asif Mughal"},"description":"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.","sameAs":["https:\/\/codehim.com"],"url":"https:\/\/codehim.com\/author\/asif-mughal\/"}]}},"views":6464,"_links":{"self":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/6350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/comments?post=6350"}],"version-history":[{"count":0,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/6350\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media\/6385"}],"wp:attachment":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media?parent=6350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/categories?post=6350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/tags?post=6350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}