JSON Formatter Pro

Related Pages: JSON Minifier.

About JSON Formatter Pro:

This pro online json formatter tool helps you to format raw JSON string so it can easily be read by human being.

This tool can force to format invalid JSON String, even if the input String doesn't comply the official JSON syntax properly.

The Advantages of JSON over XML:

JSON is simpler to read than XML, JSON use a simper grammar and less space wasted in the outside structure.

JSON is much simpler to parse than XML. JSON is very well compatible with JavaScript, while parsing XML needs complex XPath.

comic json formatter

More information about JSON (JavaScript Object Notation):

RFC 8259 (JSON): https://tools.ietf.org/html/rfc8259

Python Implementation of JSON: https://docs.python.org/3/library/json.html

Java Implementation of JSON (GSON): https://github.com/google/gson

JSON Formatter with Python (with build-in package JSON):

import json

def format_json(str):
    resultStr = json.dumps(json.loads(str), indent=4, ensure_ascii=False)
    return resultStr

JSON Formatter with Java (with package GSON):

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;

public String Format(String jsonStr){
    JsonParser parser=new JsonParser();
    JsonElement je=parser.parse(jsonStr);
    Gson gson=new GsonBuilder().setPrettyPrinting().serializeNulls().create();
    return gson.toJson(je);