jsonecho

JSON Stringify Online

Turn a JSON document into a single escaped string, ready to be placed inside another JSON value or a line of code.

Loading the tool...

How to use JSON Stringify

  1. Paste your JSON.
  2. Leave "Wrap in quotes" on if you want a complete string literal, or turn it off to get only the escaped content.
  3. Turn on "Keep indentation" if you want line breaks to stay in (as \n) instead of the compact form.
  4. Copy the result.

About JSON Stringify

Sometimes JSON needs to travel inside another string. A webhook payload that holds JSON as text, a message queue body, a test fixture in a Java or C# file, a value in a .env file. In all of those the quotes and line breaks have to be escaped or the outer text breaks.

That is what JSON.stringify does to a string. This tool does it for the whole document at once: it first validates your JSON, minifies it, then escapes the result.

Frequently asked questions

What is the difference between stringify and minify?

Minify keeps the result as JSON. Stringify goes one step further and escapes it so the whole thing becomes a string value, with every double quote written as \" and every backslash doubled.

How do I reverse this?

Use the String to JSON converter. It takes an escaped string and gives you the readable JSON back.

Why are there so many backslashes?

Each quote needs one backslash. If the text already contains backslashes, each of those becomes two. Apply the process twice and you get even more, which is a classic source of double-escaping bugs.

Can I use the output in a Java or C# string?

For most documents yes, since both languages use the same escape for double quotes. For other special characters, the Java Escape and .NET Escape tools produce code that matches each language exactly.

More in JSON Tools

All tools →