How to use this tool
- Enter text or quoted json string, action.
- Select Update result to view the result.
- Check the method and assumptions below before using the result.
Input reference and sample values
Use the units and choices shown for each field. Sample values are provided for practice, not as recommendations.
| Input | Format and units | Sample |
|---|---|---|
| Text or quoted JSON string | Keep the structure and separators shown in the sample. Line breaks are retained in this input. | Hello "world"
Second line |
| Action | Choose Escape as JSON string / Unescape JSON string. | Escape as JSON string |
Result for these sample inputs
"Hello \"world\"\nSecond line"
Select Try the example in the form to load these values and calculate them again. This replaces the current form inputs. Compare the result with the method and worked explanation below.
The method, explained
Encoding applies JSON.stringify to the entire input string. Decoding applies JSON.parse and accepts only a string value, rejecting objects, arrays and numbers.
Using text or quoted json string = Hello "world" Second line, action = encode, the result is "Hello \"world\"\nSecond line". Change these example inputs to match your task; use the method above to check each step.
What to keep in mind
This is JSON string escaping, not HTML escaping. Empty decoded strings are valid results.
Common questions
How is this different from JSON formatting?
A formatter works on a complete JSON document. This tool handles one string value and its quotes, newlines, backslashes and escape sequences.
Does my text leave my device?
Processing runs locally in this browser. Your pasted text is not uploaded to an API or stored in a ClarityKit account.
Methodology maintained by ClarityKit. How these tools are built and checked.