# `angular.toJson` (API in module `ng` )

Improve this doc

## Description

Serializes input into a JSON-formatted string.

## Usage

    angular.toJson(obj[, pretty]);

### Parameters

- `obj – {Object|Array|Date|string|number} –`

  Input to be serialized into JSON.

- `pretty(optional) – {boolean=} –`

  If set to true, the JSON output will contain newlines and whitespace.

### Returns

`{string}` –

Jsonified string representing `obj`.