FormatterHQ

String to JSON Converter

Paste an escaped JSON string from a log, database column or API field and get readable, indented JSON back. Single quotes, missing outer quotes and double encoding are handled.

Input TEXT
Output JSON
Ready.

How to use the String to JSON Converter

  1. Paste the escaped string, with or without its surrounding quotes, or click Sample.
  2. Choose an Indent of 2, 3 or 4 spaces or a tab for the result.
  3. Click Convert to JSON; with Auto update on, the output follows your edits.
  4. If the status bar shows an error, the line and column refer to the decoded JSON text. Fix it and convert again, then copy or download the result.

Turn an escaped string back into JSON

This string to JSON converter reverses stringification. When a JSON document has been stored or logged as a string, you see it full of \" and \n sequences and it is almost impossible to read. Paste that string here and the tool removes the escaping, parses the JSON inside and shows it formatted with your chosen indent.

It is built for the forms such strings actually take in the wild, not only for perfectly quoted literals.

Inputs it understands

A quoted JSON string literal

The classic case, as returned by JSON.stringify or found inside another JSON document:

"{\"user\":{\"id\":7,\"name\":\"Sara\"},\"expires\":3600}"

Escaped text without outer quotes

Log lines and database exports often drop the surrounding quotes. The tool detects the escape sequences and decodes them anyway:

{\"event\":\"login\",\"user\":\"ana\",\"ok\":true}

Result:

{
  "event": "login",
  "user": "ana",
  "ok": true
}

Single-quoted literals

Strings copied from JavaScript, Python or PHP source often use single quotes, with apostrophes escaped as \'. Input like '{"name":"O\'Neil"}' is converted to a double-quoted literal first and then decoded, so the name comes out as O'Neil.

Double- and triple-encoded JSON

When a value has been stringified twice, decoding once only gives you another string. The converter keeps unwrapping while the result is still a string that looks like JSON, up to five extra layers, so this input:

"\"{\\\"sku\\\":\\\"A-1\\\",\\\"qty\\\":2}\""

still ends as a plain object with sku and qty keys. If the input is already normal JSON, it is simply formatted.

Where escaped JSON comes from

  • Application logs that serialize the request body into a message field.
  • Database columns of type text or varchar that store a JSON document, exported to CSV or copied from a query tool.
  • Message queues and webhooks whose envelope carries the real payload as a string property.
  • Environment variables and CI secrets that hold a JSON config.

Limits and common errors

  • Only the top level is decoded. If you paste {"payload":"{\"a\":1}"}, the outer object is valid JSON, so it is formatted and payload stays a string. Copy that field's value and convert it on its own.
  • The decoded text must be JSON. A string such as "not json" decodes to plain words and is reported as an error at line 1, column 1.
  • Errors point into the decoded JSON. A trailing comma or a Python True inside the string is reported with a line and column of the unescaped document, not of your input.
  • Broken escaping. If a quote inside the string was never escaped, the literal ends early and decoding fails. Try the JSON fixer on the unescaped text.

String to JSON vs related tools

Use JSON Stringify for the opposite direction. When you need to remove escaping from any text, not just JSON, the JSON unescape tool returns plain text instead of parsed data. After decoding, the JSON viewer is handy for exploring a large payload as a tree.

Privacy

Decoding runs in your browser, which matters when the string comes from production logs. Nothing is uploaded unless you use Load URL (fetched through our server) or Save & Share (stored to create a link).

Convert a string to JSON in Python

json.loads() parses a string that contains JSON and returns a dictionary or list. If the result is still a str, the text was encoded twice, which is common for values pulled from logs, message queues and database columns; run json.loads() again on that result. A string with single quotes, True or None is a printed Python dictionary rather than JSON, and json.loads() rejects it; parse it with ast.literal_eval() instead. Do not use eval() for this, because it runs whatever code the string contains.

import ast
import json

text = '{"user": {"id": 7, "name": "Sara"}, "expires": 3600}'
data = json.loads(text)                 # str -> dict
print(data["user"]["name"])             # Sara

# A string that was encoded twice needs two passes
escaped = '"{\\"user\\":{\\"id\\":7,\\"name\\":\\"Sara\\"},\\"expires\\":3600}"'
once = json.loads(escaped)
print(type(once).__name__)              # str
print(json.loads(once)["expires"])      # 3600

# A printed Python dict is not JSON: single quotes, True, None
printed = "{'id': 7, 'active': True, 'manager': None}"
print(json.dumps(ast.literal_eval(printed)))
# {"id": 7, "active": true, "manager": null}

To see what an escaped string decodes to before writing any code, paste it above: the page unwraps it and shows the formatted JSON.

Frequently asked questions

How do I convert a JSON string back to an object?
Paste the string, with or without its outer quotes, and click Convert to JSON. The tool removes the escaping, parses the result and shows it as formatted JSON that you can copy into your code or save as a file.
Why does my string still look escaped after decoding?
The value was probably encoded more than once. This converter unwraps repeated layers automatically, but a JSON string nested inside a field of an object is left as a string. Decode that field value separately.
What does "Invalid JSON string literal" mean?
The input starts with a quote, but the quoted text is not a valid string literal, usually because an inner quote is not escaped or the closing quote is missing. Check the end of the input, or remove the outer quotes and try again.
Can I decode strings copied from Python or PHP?
Yes. Single-quoted literals are supported, including escaped apostrophes. Python's True, False and None inside the decoded JSON are not valid JSON, though, and are reported as errors.
Does it handle unicode escapes like \u00e9?
Yes. Standard JSON escapes, including \uXXXX sequences, are decoded to the real characters in the formatted output.

Last updated October 3, 2026

Related tools

JSON to Query String Build URL-encoded query strings from JSON objects, with a choice of bracket, indexed or repeated keys for arrays. JSON to String Converter Convert JSON to a single escaped string you can paste into code, databases or other JSON documents. Choose double, single or no quotes. Query String to JSON Parse URL query strings into JSON, including repeated keys, PHP/Rails bracket arrays (a[]=1) and nested objects (a[b][c]=1). XML to String Converter Convert XML to an escaped string literal for Java, C#, JavaScript or JSON. Minify first or keep lines as concatenated strings. JSON Multiline String Converter Convert multi-line text into a valid JSON string with \n escapes, a JSON array of lines, or concatenated string literals. Reverse String Reverse text by characters, words or lines, or flip the letters of each word individually. JSON Graph Visualizer Visualize JSON data as a graph of connected nodes. See objects, arrays and values as a diagram of linked boxes with size badges. jq Playground Run jq filters on JSON in your browser with real jq 1.8: live output, -r -c -s -n -S and --arg options, clear errors and a clickable cheat sheet. JSON Cleaner Clean JSON by removing null values, empty strings, empty arrays and empty objects at any depth. Optionally trim whitespace in strings. JSON Decode Online Decode JSON strings online. Convert escaped or encoded JSON text into readable, formatted JSON, similar to json_decode. JSON Deserialize Online Deserialize an escaped JSON payload into formatted JSON, then map it to typed objects in JavaScript, Python, Java or C# safely. JSON Editor Edit JSON online with a live tree preview, instant validation and one-click formatting, repair and minification.