You log an API response and get this back:

"{\"user\":{\"name\":\"John\",\"role\":\"admin\"}}"

Every quote has a backslash in front of it. The whole thing is wrapped in one more pair of quotes. It is technically valid, completely unreadable, and your parser refuses to touch it.

Here is the part that trips people up: sometimes this is exactly what you asked for, and sometimes it is a bug. The characters look identical either way. This guide explains what the backslashes mean, when to keep them, and how to spot the case where something upstream has encoded your data twice.

What a Backslash Is Actually Doing

A JSON string is delimited by double quotes. So what happens when the text inside needs a double quote of its own? The parser would stop early and everything after would be garbage.

Escaping solves it. A backslash tells the parser "the next character is data, not syntax":

He said "hi" ← raw text "He said \"hi\"" ← the same text as a JSON string

The backslashes are not part of your data. They are punctuation that disappears the moment the string is parsed. This matters because it means backslashes multiply every time you wrap data in another layer of string.

Watch a Windows path go through two layers:

C:\Users\file.txt ← the actual value "C:\\Users\\file.txt" ← inside JSON "{\"path\":\"C:\\\\Users\\\\file.txt\"}" ← that JSON inside a string

One backslash becomes two, then four. Nothing is wrong here — each layer is escaping the layer below it. The trouble starts when a layer gets added that nobody intended.

Minified, Escaped, or Pretty?

"Convert JSON to string" can mean three different things, and picking the wrong one is the usual cause of confusion. Take this input:

{ "name": "John", "tags": ["a", "b"] }
Format Output Use it for
Minified {"name":"John","tags":["a","b"]} Sending over the network, storing in a JSON column
Escaped "{\"name\":\"John\",\"tags\":[\"a\",\"b\"]}" Pasting JSON inside another string
Pretty Indented across multiple lines Reading and debugging

Minified and pretty hold the same data in different shapes — we pull that difference apart in Format vs Minify vs Validate. Escaped is the odd one out: it is no longer a JSON object at all. It is a string that happens to contain JSON.

The key distinction Minified JSON parses straight into an object. Escaped JSON parses into a string — you then have to parse that string a second time to get your object back. Two different things, one letter apart in most menus.

When Backslashes Are Correct

Escaped JSON is the right answer whenever the JSON has to survive being carried inside something that is itself a string.

  • Embedding in source code. Assigning a JSON payload to a variable in a test, a fixture file, or a config constant — the whole thing has to be a valid string literal in that language.
  • A JSON field that holds JSON. Event payloads, webhook bodies, and audit logs often stash a whole document inside a single field. That field is a string, so its contents must be escaped.
  • Message queues and log lines. Anything that transports opaque text rather than structured data needs the payload flattened into one escaped string.
  • Database text columns. Storing JSON in a plain TEXT or VARCHAR column rather than a native JSON type.

In all four cases the backslashes are doing real work. Strip them out and the surrounding structure breaks.

When Backslashes Are a Bug

The bug has a specific name: double encoding. Something serialised your data, then something else serialised the result again, treating the already-finished JSON as if it were ordinary text.

The classic version in JavaScript:

const payload = JSON.stringify(data); // now a string send(JSON.stringify(payload)); // stringified again

Each pass adds a layer, and the backslashes roughly double every time. Three passes and the payload is unreadable.

It usually creeps in at a boundary where two people made the same reasonable assumption:

  • An HTTP client that serialises the body automatically, handed a body that was already serialised
  • A logging wrapper that stringifies whatever it receives, including finished JSON
  • A framework that encodes a response, wrapping a value the handler had already encoded

The fix is never to add a decoding step at the end. It is to find the extra encode and remove it — serialise once, at the last moment before the data leaves your process.

Parsing twice hides the problem When double-encoded data arrives, it is tempting to just call parse twice and move on. That works until a payload comes through encoded once — or three times — and the same code breaks. Fix the encode, not the decode.

How to Tell Which One You Have

Look at the very first character of the value.

Starts with What it is Verdict
{ or [ A JSON object or array Normal
"{\" A string containing JSON Correct only if intended
"\"{ A string containing a string containing JSON Double encoded

The second row is the one that needs judgement. If your API contract says that field carries an escaped document, it is fine. If you expected an object there, something added a layer.

The third row is never intentional. An escaped quote sitting before the opening brace means the wrapper itself has been wrapped again — and further in you will see doubled backslashes like \\\", which is the escape characters having been escaped. That only happens when the data went through encoding twice.

Converting JSON to a String

  1. Open the JSON to String converter.
  2. Put the document in the left editor. Typing works, and so does Upload for anything under 100 MB.
  3. Choose the output. Minified if it is being sent or stored, Escaped if it is going inside another string, Pretty if you just need to read it.
  4. Hit Convert. Grab the result with Copy, or save it as data.txt if you would rather keep a file.

Broken JSON is caught before anything is converted, so a syntax error surfaces straight away instead of quietly producing a mangled string. All of it happens on your machine — the document is never sent anywhere.

Going the other way Received an escaped blob and need the object back? String to JSON unwraps it, and our guide on why valid JSON refuses to parse walks through peeling one layer at a time. And if the JSON will not parse at all, the JSON Formatter points at the exact line that is broken.
Try it now — CodBolt JSON to String

Minified, escaped, and pretty output in one place. Free and 100% private.

Open Tool