jsonecho

JSON to String

Turn JSON into one escaped line that you can drop between double quotes in your code.

Loading the tool...

How to use JSON to String

  1. Paste your JSON.
  2. Copy the escaped result and put it between double quotes in your code.

About JSON to String

This is the tool you want when a test needs a JSON payload as a string. You write String body = "...";, and every double quote inside the JSON has to be escaped. Doing that by hand on a 40 line document is tedious and easy to get wrong.

Paste the document and the escaped text comes out as a single line without the outer quotes, so you can paste it between your own. If you do want the quotes included, tick the box.

Frequently asked questions

Is this different from JSON Stringify?

The engine is the same. This page defaults to no outer quotes, which is what you want when you paste into an existing string. The Stringify page defaults to a complete string literal.

Does it work for Python?

Yes for most documents, since Python uses the same escapes for double quotes and backslashes. For Python you may prefer triple quotes, which need no escaping at all.

How do I turn the string back into JSON?

Use String to JSON. It unescapes the text and formats the JSON for you.

More in Converters

All tools →