An open API service indexing awesome lists of open source software.

https://github.com/angeal185/json-min-max

json minify and beautify for nodejs or browser
https://github.com/angeal185/json-min-max

beautify json minification minify pretty-print

Last synced: about 1 month ago
JSON representation

json minify and beautify for nodejs or browser

Awesome Lists containing this project

README

          

# json-min-max
##### json minify and beautify for nodejs or browser

### Installation

npm:
```sh
$ npm install json-min-max --save
```

#### server-side example

```js
const JMM = require('json-min-max');

// minify
fs.readFile('./unminified.json', 'utf8', (err, data) => {
if (err) throw err;
console.log(JMM.minify(data));
});

// beautify
fs.readFile('./minified.json', 'utf8', (err, data) => {
if (err) throw err;
// default indentation is 2
console.log(JMM.beautify(data,4));
});
```
#### browser example

```html

<script>
// minify
let x = document.getElementById('unminifiedData').value;
console.log(JMM.minify(x));

// beautify
let y = document.getElementById('minifiedData').value
console.log(JMM.beautify(y,2));

```