-   Under 1 min read

Minify JSON

Another way to minify JSON is to use the npm package.


npm install -g json-minify


Having a test-data.json file

  "friends": [
      "id": 0,
      "name": "Amparo Henry"
      "id": 1,
      "name": "Stone Ferguson"
      "id": 2,
      "name": "Cheryl Rocha"

Defaults to stdout

tan@omega:~$ json-minify test-data.json
{"friends":[{"id":0,"name":"Amparo Henry"},{"id":1,"name":"Stone Ferguson"},{"id":2,"name":"Cheryl Rocha"}]}

Write to new file

json-minify test-data.json > minified.json

Or use it as pipe

tan@omega:~$ curl -s http://elasticsearch:9200 | json-minify
{"name":"dev","cluster_name":"fo-test","cluster_uuid":"sE_HoGSZRKyhGHN9lk2gSA","version":{"number":"5.4.3","build_hash":"eed30a8","build_date":"2017-06-22T00:34:03.743Z","build_snapshot":false,"lucene_version":"6.5.1"},"tagline":"You Know, for Search"}

Tan-Vinh Nguyen

Just a coder

Similar Stories


Convert JSON 2 CSV in JavaScript

json2csv is java script library which allows conversion of the format csv and json on a linux terminal.

Read on


Code Review - Boolean's Delight

Did some code review and saw some fancy lines :-( It is about JSON handling with Jackson. Basically is about how to determine that a given `JsonNode` is not null and a container. Read on


Convert from CSV to JSON with logstash

logstash allows with various plugins a quick solution, to convert CSV input to JSON output. Read on