<commit_before># console.json

> Adds console.json method for convenience

[![NPM][console.json-icon] ][console.json-url]

[![Build status][console.json-ci-image] ][console.json-ci-url]
[![dependencies][console.json-dependencies-image] ][console.json-dependencies-url]
[![devdependencies][console.json-devdependencies-image] ][console.json-devdependencies-url]

[Demo](http://glebbahmutov.com/console.json/demo/)

Install: `npm install console.json --save`

Use:

```js
// call once somewhere in the beginning
require('console.json');
var foo = {
    n: 21,
    bar: {
      a: ['first', 'second']
    }
};
// console.json('foo', foo); prints
foo {
  "n": 21,
  "bar": {
    "a": [
      "first",
      "second"
    ]
  }
}
// console.log('foo', foo) prints
foo { n: 21, bar: { a: [ 'first', 'second' ] } }
```
## Options

You can pass arguments to be used inside `JSON.stringify` to `console.json`

```js
require('console.json')(null, 4);
// aligns printed properties using 4 spaces
```

For exact meaning of these two arguments, see
[JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)

### Small print
<commit_msg>showed how to use in the browser<commit_after># console.json

> Adds console.json method for convenience

[![NPM][console.json-icon] ][console.json-url]

[![Build status][console.json-ci-image] ][console.json-ci-url]
[![dependencies][console.json-dependencies-image] ][console.json-dependencies-url]
[![devdependencies][console.json-devdependencies-image] ][console.json-devdependencies-url]

[Demo](http://glebbahmutov.com/console.json/demo/)

Install: `npm install console.json --save`

## Use:

node:

```js
// call once somewhere in the beginning
require('console.json');
var foo = {
    n: 21,
    bar: {
      a: ['first', 'second']
    }
};
// console.json('foo', foo); prints
foo {
  "n": 21,
  "bar": {
    "a": [
      "first",
      "second"
    ]
  }
}
// console.log('foo', foo) prints
foo { n: 21, bar: { a: [ 'first', 'second' ] } }
```

browser:

```html
<script src="node_modules/console.json/index.js"></script>
<script>
console.json({ foo: 'bar' });
</script>
```

## Options

You can pass arguments to be used inside `JSON.stringify` to `console.json`

```js
require('console.json')(null, 4);
// aligns printed properties using 4 spaces
```

For exact meaning of these two arguments, see
[JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)

### Small print

{'fraction_non_alphanumeric': 0.18593563766388557, 'fraction_numerical': 0.006356773937226857, 'mean_word_length': 4.046092184368738, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3150689', 'n_tokens_mistral': 898, 'n_tokens_neox': 849, 'n_words': 198}