String to JSON Converter
FV-30Paste a string that holds JSON and click String to JSON. It unwraps quoted strings, removes backslash escapes and, if you allow it, accepts single quotes and unquoted keys.
Runs in your browser. Nothing is uploaded.
A string that holds JSON
JSON
How to use it
- Paste the string into the input box. It can be quoted, escaped or plain JSON.
- Choose the indent, and keep Lenient on if the text may use single quotes, unquoted keys or comments.
- Click String to JSON for formatted output, or String to minified JSON for one line.
- Copy the result or download it as a .json file.
Three readings, in order
First the tool reads the text as strict JSON. If it is a quoted string whose content is JSON, that content is unwrapped, up to five levels deep. Second, it tries text with backslash escapes but no outer quotes, such as {\"a\":1}. Third, with the lenient option on, it applies JSON5 rules, which accept single quotes, unquoted keys, comments and trailing commas.
Numbers and the lenient mode
The strict readings keep numbers exactly as written. The lenient reading turns numbers into JavaScript numbers, so a value of 16 or more digits is refused with an error rather than rounded. Put such a value in quotes or turn the lenient option off. The output is always standard JSON with double quotes. Plain words that are not JSON at all give an error.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
This is not valid JSON, even with the lenient rules. | The text could not be read as JSON or JSON5. | Check for a missing bracket, quote or comma at the position given. |
Lenient mode reads numbers as JavaScript numbers | The lenient reading found a number of 16 or more digits that could be rounded. | Turn off the lenient option, or put that value in quotes. |
Questions people ask
How do I convert a string to JSON?
Paste the string and click String to JSON. If it is a stringified JSON value, with outer quotes and escaped inner quotes, the tool unwraps it. If it already is JSON, it is formatted. The output uses your chosen indent.
How do I fix escaped JSON with backslashes before the quotes?
Paste it as it is, even without outer quotes. Text like {\"id\":1} is detected, the backslash escapes are removed, and the result is parsed and indented as normal JSON.
Can it parse single-quoted or unquoted JSON?
Yes, when the Lenient option is on. It uses JSON5 rules for single quotes, unquoted keys, comments and trailing commas, and writes standard JSON with double quotes. With Lenient off, only strict JSON is accepted.
What if my string holds JSON inside JSON?
The tool unwraps up to five levels. A string containing a string containing an object ends up as the formatted object. If an inner level is not JSON, it stops there and keeps that level as text.
Why was my big number rejected?
Only the lenient reading can round numbers, because it uses JavaScript numbers, which hold about 15 to 17 significant digits. To avoid silent changes, a value with 16 or more digits stops with an error. Quote it or turn Lenient off.
About this tool
The tool tries three readings in order. First, strict JSON: if the text is a quoted string whose content is JSON, the content is unwrapped, up to five levels deep. Second, backslash-escaped JSON without outer quotes, such as {\"a\":1}, is unescaped and parsed. Third, if the lenient option is on, JSON5 rules accept single quotes, unquoted keys, comments and trailing commas. Strict readings keep numbers exactly as written. The lenient reading uses JavaScript numbers, so a value of 16 or more digits is refused rather than rounded. Output is standard JSON with double quotes. Plain words that are not JSON are an error. Nothing is uploaded.