Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reformat JSON in Notepad++?

I need Notepad++ to take a json string from this

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

to this...

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

I looked around at all the TextFX options but couldn't find anything that worked.

like image 756
Donny V. Avatar asked Oct 13 '09 14:10

Donny V.


People also ask

Can notepad edit JSON file?

JSON is a plain text file that can be opened in a text editor. You can easily modify and save it back without any special software.

Does Notepad++ have a JSON formatter?

Notepad++ has limited support for the validation of JSOn content. JSON formatter gives an error or warning during the format of an opened json file. You can also check JSON viewer to check for invalid json content.

How do I format JSON?

You can format your JSON document using Ctrl+Shift+I or Format Document from the context menu.

How do I indent JSON in Notepad++?

To format and indent the code: select all the json fragment. click "Plugins"/"JSON Viewer"/"Format JSON" or use the shortcut Ctrl + Alt + Shift + M.


1 Answers

Update:

As of Notepad++ v7.6, use Plugin Admin to install JSTool per this answer

INSTALL

Download it from http://sourceforge.net/projects/jsminnpp/ and copy JSMinNpp.dll to plugin directory of Notepad++. Or you can just install "JSTool" from Plugin Manager in Notepad++.

New Notepad++ install and where did PluginManager go? See How to view Plugin Manager in Notepad++

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

enter image description here Tip: Select the code you want to reformat, then Plugins | JSTool | JSFormat.

like image 189
Dan H Avatar answered Sep 20 '22 03:09

Dan H