JSON Formatter Plugin for IntelliJ

05 Feb, 2009

When developing an AJAX application you often end up with some data interchange format, like XML, plain text, or, in my case: JSON. The trouble with JSON, however, it that’s it’s quite hard to read. Not because it’s so complicated, but because it has been optimized for network communication, which in this case, means: all the whitespace has been stripped. Wouldn’t it be nice to have an integrated JSON formatter in your IDE to handle this? Well, now it possible!

What I did was to create a plugin for IntelliJ, to format your JSON code into some more readable (and formatted) code. Since a picture says more than a thousand words: a picture for your viewing pleasure:
IntelliJ JSON Formatter
What you can see in the screenshot is the following JSON code, but formatted:

{"glossary":{"GlossDiv":{"GlossList":{"GlossEntry":{"Abbrev":"ISO 8879:1986","Acronym":"SGML","GlossDef":{"GlossSeeAlso":["GML","XML"],"para":"A meta-markup language, used to create markup languages such as DocBook."},"GlossSee":"markup","GlossTerm":"Standard Generalized Markup Language","ID":"SGML","SortAs":"SGML"}},"title":"S"},"title":"example glossary"}}

By pasting the above in the plugin, and clicking on ‘format’, you’ll end up with the result as seen in the screenshot, which is much more readable, and thanks to the RSyntaxTextArea has colors and braces matching. The plugin doesn’t do validation yet, but this is a helpful addition to make the JSON even more readable!
So, please check out the plugin (you can install it from IntelliJ’s integrated plugin manager), install the JSON Formatter plugin and tell me what you think of it!

Newest Most Voted
Inline Feedbacks
View all comments
13 years ago

I tried your plugin, its really good. I can suggest two features. one is converting the formatted json to xml and the other is converting it into tree structure. If you can share the code may be I can help with the development. Let me know . my email is
vivekmongolu at gmail dot com
wanted to extend it further by

9 years ago

Indeed, very handy.
Would be great to have it:
1. Integrated into Idea formatting framework so you can customize presentation
2. Display as tree +1

9 years ago

Can you please add a checkbox to disable validation.

9 years ago

One suggestion/request or question. Can this be integrated with the comparison tool in IntelliJ. Would be great for unit tests to see differences (readily) between expected and actual JSON strings.

5 years ago

I am not able to install it in Intellij 16. Any reasons? I am not able to see in the search results itself. Do I need to any plugin repositories?

4 years ago

I use intellij and big fan of it and I think this would be a good plugin. Sometime I use for Formatting and Validating JSON data.

Explore related posts