How to convert a string to JSON without losing track of the data
To convert a string to JSON, first check whether you have JSON text or a string containing that text. This string-to-JSON conversion example covers both inputs.
A payload copied from a log can be hard to read. You might have an object squeezed onto one line, or a quoted string full of backslashes. Before changing anything, look at the outermost characters. They tell you which kind of input you have.
Start with a small example
This is an object written as JSON text. Its keys use double quotes, and its values include both a string and a number.
{"name":"Maya","attempt":2}Paste it into the String to JSON converter. With two-space indentation selected, the same data becomes easier to scan:
{
"name": "Maya",
"attempt": 2
}Indentation changes the layout. It does not turn the number into text or rename a field. If you need a compact document again, choose Minified.
When the whole object is inside a string
An extra pair of outer quotes means you may be looking at JSON that contains JSON text. The inner quotes need escaping because they belong to the string value.
"{\"name\":\"Maya\",\"attempt\":2}"Use String → JSON for this input. The converter parses the outer string and tries to parse its contents again. It stops when the value can no longer be parsed, or after its limit of 32 unwrapping steps. For this example, the output is the object shown above.
Choose the mode that matches your task
JSON Formatter keeps the document's value as it is and changes its layout. Use that mode when a top-level string should stay a string. JSON Validator checks syntax. JSON → String creates a quoted, escaped representation that you can copy into a payload.
Leave Sort keys off if you want to inspect the incoming field order. Turn it on when a consistent display order helps you compare ordinary objects. Array elements keep their original order.
Check the output before saving
Confirm the top-level type in the status bar and read the fields you care about. A successful parse establishes that the syntax is valid; it cannot tell whether an application expects those fields or whether their values are correct.
Watch long numeric identifiers, too. This converter uses JavaScript numbers, so sufficiently large integers can lose digits during parsing. If an identifier must retain its exact spelling, the producer should send it as a quoted string.
Copy the result or save it as a file once you have checked it. File selection and conversion happen in your browser. You can read about optional page analytics in the Privacy Policy.