11

I've got some JSON data, but it's all on one line. Does anyone know of a web or Windows editor that will format (e.g. indent and insert new lines) this data for me, so I can read it better? Preferably one that uses a GUI to display the JSON—instead of a command-line tool that outputs a reformatted document, for example.

core
  • 30,054
  • 41
  • 131
  • 189

8 Answers8

8

I have recently created JSON Editor Online, a tool to easily edit and format JSON online. JSON is displayed in a clear, editable treeview and in formatted plain text.

http://jsoneditoronline.org/

Jos de Jong
  • 5,819
  • 3
  • 32
  • 51
  • Haha. It's great. Before I found yours, my attempt was chrome dev tools > js console > write var x = *my_json*. Then I explore it the geeks way :P – asakura89 Aug 31 '12 at 03:30
  • Well designed and easy to use. Great work! – Daniel Jan 31 '13 at 15:37
  • well done. Very quick and smooth. – PJH Oct 16 '13 at 15:29
  • I tried your tool an it's very nice. But, it will not validate valid JSON where there is a mutilined string assignment. The string has to be continuous without line breaks. – A.G. Nov 09 '13 at 17:28
5

Have you tried this?

http://jsonformat.com/

Bob
  • 90,304
  • 29
  • 114
  • 125
5

You can download http://www.thomasfrank.se/json_editor.html and run it locally on your own data, although it is an editor rather than a formatter.

http://www.jsonlint.com/ is also a useful validation and reformatting tool.

mpdaly
  • 1,159
  • 6
  • 6
5

On windows I go for: http://jsonviewer.codeplex.com/

Handy for pulling raw JSON responses from Firebug and parsing it for me.

Ray Leyva
  • 51
  • 1
  • 3
2

I use http://curiousconcept.com/jsonformatter to format computer generated jsons. It makes it much readable.

Andres
  • 1,855
  • 1
  • 19
  • 27
  • pretty good -- shows you exactly where your syntax is wrong ( but not as-you-type, only when you click to "process" button ) – Nick Perkins Aug 14 '11 at 20:49
2

Remember that JSON is just a Javascript Object Literal with fancy clothes. You should be able to use any Javascript Beautifier to clean it up.

Alan Storm
  • 157,413
  • 86
  • 367
  • 554
0

I like this one here: http://freeformatter.com/json-formatter.html

The validation process is flexible if your doc does not adhere to the RFC standards. It also creates a tree with collapsible nodes which is cool when you want to work in a small area of the json tree

0

Here's what I do: use the Aptana Eclipse Javascript Editor, which will check your syntax as you type. There's only one trick: you have to wrap your json in a tiny bit of javascript to make the whole thing a valid javascript file, and eliminate those red and yellow syntax errors.

So, the outer-most {} becomes: x={}; ( with all your json stuff in the middle ).

Now you just have to strip-off the x= and the ; before parsing as JSON. I do this in a function that wraps the jQuery ajax function:

function get_json_file(url,options,callback){
    var opts = {dataType:"text"};
    opts.url = url;
    $.extend(opts,options);
    opts.success=function(data){
        var json = data.substring(data.indexOf('{'),data.lastIndexOf('}')+1);
        var obj = JSON.parse(json);
        callback(obj);
    };
    $.ajax(opts);
}

It's a bit crazy, but it's worth it to effectively have a really good syntax-checking JSON editor in eclipse.

Nick Perkins
  • 7,284
  • 6
  • 36
  • 39