How to format JSON in Notepad++?

beginer
beginer
154 Points
47 Posts

Raw string Json:

{ "myMenu" : { "id" : "file", "value" : "File", "popup" : { "menuitem" : [{ "value" : "New", "onclick" : "CreateNewDoc()" }, { "value" : "Open", "onclick" : "OpenDoc()" }, { "value" : "Close", "onclick" : "CloseDoc()" } ] } } }

I want to format string json formatting to tree structure json formatting in Notepad++. Something like:

{
  "myMenu" : {
    "id" : "file",
    "value" : "File",
    "popup" : {
      "menuitem" : [{
      "value" : "New",
          "onclick" : "CreateNewDoc()"
        }, {
          "value" : "Open",
          "onclick" : "OpenDoc()"
        }, {
          "value" : "Close",
          "onclick" : "CloseDoc()"
        }
      ]
    }
  }
}
Views: 126
Total Answered: 1
Total Marked As Answer: 1
Posted On: 08-Jul-2020 23:24

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Moderator
1244 Points
217 Posts
         

You require a plugin to format JSON. For Notepad++ v.7.6 and above Plugins Admin... is available. And we can easily install plugin as follows:

  1. Open Menu Plugins > Plugins Admin...
  2. Search JSON Viewer and Check JSON Viewer in List
  3. Click on Install Button. It will restart Notepad++.


Now create new window and past your json string and follow following steps to format:

  1. Select JSON string text
  2. Go to Plugins > JSON Viewer > Format JSON ( Ctrl + Alt + Shift + M )
  3. Also, we can select json from Language menu for coloring and more


We can install any Notepad++ supported plugins using Plugins Admin...

Posted On: 11-Jul-2020 04:30
 Log In to Chat