String escape & unescape
Escape and unescape string literals.
Enable JavaScript to use this interactive tool. Paste input, choose options, then copy or download the result, or save it to your notebook.
Example and common questions
Put a small configuration fragment inside a JSON string without accidentally adding a real line break to the literal. Select JavaScript or Java when that is the destination language; the supported escape sequences differ.
How to turn multiline text into a JSON string
- Choose escape and the destination string language.
- Select include quotes for a complete literal, or content-only when the surrounding quotes already exist.
- Paste the text, run the tool, and inspect the escaped line breaks before copying it.
Escape a multiline configuration fragment
- Direction
- escape
- String language
- json
- Quotes
- include
service=orders
region=ap-southeast-1"service=orders\nregion=ap-southeast-1"Which language should I select?
Choose the intended JSON, JavaScript or Java string rules. Their supported escapes differ; an escape accepted for JavaScript may be invalid for Java or JSON.
Should quotes be included?
Use include for a complete quoted string literal. Use content-only for escaped text without its surrounding quotes. The setting applies when escaping and unescaping.
Does this execute code?
No. The tool reads and transforms supported string literals without evaluating source code or running a program.
Common errors and limitations
Check for incomplete quoted literals, unsupported escapes and unescaped line breaks inside a literal. Match the selected language and quote setting to the input.