JSON Minifier
JSON Minifier

What is JSON

  • JSON is a javascript object notation, which uses the standard text-based format for storing data, based on the javascript object syntax.
  • JSON simplifies the transfer of data between server and client on the web. There are other formats used such as XML, but JSON got more popular these days as it is more human-friendly and easy to transfer between client and server on the web.
  • When you need to transfer json data in the web, you can use this tool to minify the json which reduces the size of json and it becomes easy to transfer over the network.

Example JSON

{
  "errMsg": "SUCCESS",
  "serviceStatus": "0000",
  "accounts": [
    {
      "subProductType": "Mutual Fund Portfolio",
      "accountID": "100003954091",
      "sidNumber": "",
      "sreNumber": "",
      "accgroup": "WEALTH",
      "accType": "MUTUAL FUND",
      "errmsg": "SUCCESS",
      "totalProduct": "1",
      "totalInvestment": "700000.00",
      "totalReturn": "350000.00",
      "totalCurrentValue": "1050000.00"
    }
  ]
}     

Advanced JSON Minifier

  • Advanced Online JSON minifier is an online tool to minify JSON which will reduce the size of JSON. So, it can be very compact to share over the network.
  • This advanced JSON minifier tool is a full-fledged text editor in which you can search for particular text, jump to a particular line, delete all the contents of the editor, copy the text contents of the editor, wrap the line and you can make the editor full screen and full-screen window mode.
  • You can validate the JSON entered by clicking on the Validate Icon
    in the respective editor.
  • This advanced editor supports json syntax highlighting for better understandability.
  • And there is also JSON linting available in this editor, when you hover mouse over red dot in the editor, it shows the error message inside the editor itself.
Linting feature for json
Json Linting
  • You can download the JSON in the editor as a text file, JSON file, and pdf file formats. All you need to do is to choose the file type from the dropdown and click on the Download Icon
    in the respective editor.
  • You can name the download file as you wish. Enter the download file name in the download file name text box.
  • You can format or beautify the JSON using the format/beautify button , Minify the JSON using the minify button , and Validate the JSON using the validate button .
  • You can auto-minify the JSON by checking the auto-update on the edit checkbox Auto update on edit
  • In case of an accidental reload of this website, editor preserves the input json and populate the editor with the last entered json.
  • This online json minifier works by removing the unwanted white spaces and new line characters, which will reduce the size of the json data.
  • This minified json data is widely used for transferring data in the web, this reduces the data to be transferred over the network which will reduce the bandwidth consumed. You can use the Json Formatter
    to format the json data for better readability.
  • You can use the Json Validator
    to validate json.

Why Use Json?

  • It is human-readable and does not have any mark-up structure like xml.
  • Can be easily parsed in any programming language and have evaluating support in all programming languages.
  • Can hold number of data without affecting the readability of data ( if it is formatted ).
  • Can be used to share data between two services that run on different tech stack without modifying anything in those services.
  • It has become a standard in web for sharing structured data between services.
  • Supports data types such as string, numbers, null, boolean, json object, array.
  • Can be easily converted between string and object.

Json Syntax

  • Json object should be encapsulated by curly braces {}.
  • Arrays in json is encapsulated by square brackets [].
  • Empty json object should be encapsulated by curly braces {}.
  • The json data should be key-value type.
  • The key and value should be enclosed by double-quotes.
  • Each key-value pair should be separated by comma “,” .
  • Json supports boolean, numbers, null, json object, string, array data types.
  • boolean data type can have true or false in lower case and does not include double-quotes.
  • Empty json array can be represented by [].
  • Mime type for json files is “application/json” as defined in MDN
    .
  • Extension for json file is fileName.json .
{
  "jsonObject": {
    "id": "2489651045",
    "type": "CreateEvent",
    "actor": {
      "id": 665991,
      "login": "petroav",
      "gravatar_id": "",
      "url": "https://api.github.com/users/petroav",
      "avatar_url": "https://avatars.githubusercontent.com/u/665991?"
    }
  },
  "jsonArray": [
    {
    "id": "2489651051",
    "type": "PushEvent",
    "actor": {
      "id": 3854017,
      "login": "rspt",
      "gravatar_id": "",
      "url": "https://api.github.com/users/rspt",
      "avatar_url": "https://avatars.githubusercontent.com/u/3854017?"
      }
    }
  ]
}

How To Use Json In Javascript

You can use the JSON.parse(inputString) to parse the json from string in javascript.

  • Example :

  var stringToJsObject=JSON.parse("{\"jsonObject\":{\"id\":\"2489651045\",\"type\":\"CreateEvent\",\"actor\":{\"id\":665991,\"login\":\"petroav\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/petroav\",\"avatar_url\":\"https://avatars.githubusercontent.com/u/665991?\"}},\"jsonArray\":[{\"id\":\"2489651051\",\"type\":\"PushEvent\",\"actor\":{\"id\":3854017,\"login\":\"rspt\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/rspt\",\"avatar_url\":\"https://avatars.githubusercontent.com/u/3854017?\"}}]}");
  console.log(stringToJsObject.jsonObject.type);
  console.log(stringToJsObject.jsonArray[0].actor.avatar_url);
  

You can use the JSON.stringify(inputJsonObject) to get the string representation of the JSON.


  var stringToJsObject=JSON.parse("{\"jsonObject\":{\"id\":\"2489651045\",\"type\":\"CreateEvent\",\"actor\":{\"id\":665991,\"login\":\"petroav\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/petroav\",\"avatar_url\":\"https://avatars.githubusercontent.com/u/665991?\"}},\"jsonArray\":[{\"id\":\"2489651051\",\"type\":\"PushEvent\",\"actor\":{\"id\":3854017,\"login\":\"rspt\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/rspt\",\"avatar_url\":\"https://avatars.githubusercontent.com/u/3854017?\"}}]}");
  var JsObjectToString=JSON.stringify(stringToJsObject);
  console.log(JsObjectToString);
  

What You Can Do?

  • Minify JSON
  • Format / Beautify JSON
  • Validate JSON
  • Download the JSON as .txt file, .json file and as pdf file.

Limitations

  • When you try to upload file greater than 5MB, you will not be able to edit in the text editor as browser will not be able to handle large text and cause the browser to freeze.
  • But you can still format/beautify, minify, validate and download the json.
  • If you try to download the large file as pdf, it may take some time to prepare the pdf. Please be patience.