>_devtools

JSON Stringify

Encode a JSON document as a single JSON string literal, ready to embed in code or another JSON payload.

What this does

Takes a JSON document and encodes it as a single JSON string, the result of calling JSON.stringify on a string that contains JSON. You need this when a JSON payload has to travel inside another JSON field, an environment variable, a test fixture, or a line of source code.

The input is validated first, so a syntax error is reported with its line and column rather than producing a broken string.

Minify first

With Minify first on (the default) whitespace is removed before encoding, giving the shortest string. Turn it off to keep your original formatting, with line breaks escaped as \n.

To go the other way, use Parse Stringified JSON.

Example

Input:

{ "id": 7, "name": "Ada" }

Result:

"{\"id\":7,\"name\":\"Ada\"}"

Privacy

Everything runs in your browser. Your input is never uploaded, stored, or put in the page URL.