Escape and unescape a JSON string
Convert text to an escaped string or decode escaped sequences so nested JSON, logs, and code literals are easier to inspect.
Open the tool, then paste the sample input below. Everything runs locally in your browser.
The problem
Logs and API payloads often contain JSON inside a string, with quotes and newlines escaped. Unescaping that string makes the real content readable; escaping text helps paste it safely into code or JSON.
Sample input
{"message":"hello\nworld","ok":true}
Expected output
{"message":"hello
world","ok":true}
How to do it
- Paste the escaped string.
- Choose unescape or decode mode.
- Review the decoded text.
- Switch to escape mode when preparing a literal.
- Copy the result into the target file or payload.
Common mistakes
- Unescaping twice and changing valid backslashes.
- Confusing URL encoding with string escaping.
- Pasting a full JSON object where only a string literal is expected.
- Missing newline escapes when embedding text in code.
Related tools
FAQ
When should I unescape a string?
Unescape when quotes, newlines, or backslashes are encoded and you need to read the original text.
Is string escaping the same as URL encoding?
No. String escaping handles code or JSON literal characters; URL encoding handles characters in URLs.
Is my text uploaded?
No. Escaping and unescaping run locally in your browser.
Is my data uploaded anywhere?
No. This workflow runs locally in your browser unless you explicitly copy or share the result yourself.
This guide uses browser-local tooling. Avoid pasting production secrets unless you understand what the tool displays and shares.
Continue with adjacent browser-based tools for the same workflow.
Escape JSON strings safely: quick answer
Use this when logs, config files, environment variables, or test cases need a JSON string literal rather than a raw object. Paste or load the artifact into the linked tool, run the local check, then copy only the safe result or summary into your PR, ticket, or test notes.
What to verify
Check quotes, backslashes, newline escapes, embedded JSON, and whether the target expects escaped text or parsed JSON. If a result will be shared outside your team, run a privacy or secret scan first and replace real values with safe examples.
Recommended next steps
- Open String Escaper for the main task.
- Use JSON Formatter when you need a second validation pass.
- Return to Use Cases to find related workflows for the same artifact.
Practical example and expected result
Convert text to an escaped string or decode escaped sequences so nested JSON, logs, and code literals are easier to inspect. In practice, this is most useful when you need a quick, repeatable check on a JSON payload before adding it to a ticket, pull request, test fixture, or support note.
A realistic input for this workflow is {"message":"hello\nworld","ok":true}. The expected result should resemble {"message":"hello world","ok":true}, with the same important values preserved.
Troubleshooting checklist
- Confirm you copied the complete JSON payload and not only a partial line or truncated preview.
- Run the local tool once with a safe sample, then repeat with the real data only if your team policy allows it.
- Check quoting, escaping, whitespace, encoding, timestamps, and environment-specific values before trusting the result.
- Before sharing output, remove secrets, tokens, cookies, customer data, and production hostnames that are not needed for the review.
Next useful steps
- Open this example in String Escape / Unescape → for a related validation or follow-up step.
- JSON Formatter for a related validation or follow-up step.
- URL Encoder for a related validation or follow-up step.
- Use Magic Box when you are not sure which tool should handle the next artifact.
Review checklist before sharing the result
For Escape and unescape a JSON string, the safest workflow is to test with a small sample, confirm the output shape, then repeat with the real artifact only when needed. Keep the original input open until you verify that no value was dropped, decoded twice, sorted unexpectedly, or changed from text into a different type.
Before copying the result into a pull request, issue, chat thread, or support ticket, scan for private values. Replace real IDs, bearer tokens, session cookies, email addresses, internal hostnames, and customer data with placeholders. If another tool is listed above, use it as the second pass rather than manually editing complex output.
- Keep one line of context explaining why the transformation was needed.
- Preserve enough sample structure for a reviewer to reproduce the result locally.
- Note any assumptions about encoding, timezone, delimiter, schema version, or runtime environment.