Escape and unescape strings
Escape or unescape text for JSON, JavaScript or regular expressions.
Your files are processed here, on your device
We do not send your file or text contents to a processing server. No account is needed and there is no daily operation quota. Individual tools have size limits to protect your device’s memory.
A connection is needed to load the site and its resources. Hosting may receive technical visit data. Favorites store only tool identifiers in this browser.
How we handle your data →How to use this tool
- Paste the text and choose the target.
- Choose Escape or Unescape.
- Copy the result inside your quotes or pattern.
An example you can verify
Prepare text to paste inside a JSON string, JavaScript or a regular expression.
Example input
He said: "hello" and a second line.
Expected result
He said: \"hello\"\nsecond line, ready to paste between quotes.
Paste the result inside the quotes in your code and check that the original value is recovered. To undo it, use Unescape.
Escape and unescape strings: uses and practical guidance
A text literal in code contains characters that cannot be written as they are: the quotes that close it, the backslash or a line break. Escaping means replacing them with a sequence the language understands, such as \" for a double quote or \n for a line break. This tool does it for JSON, for JavaScript with single quotes and for regular expressions, where characters with special meaning are protected.
Choose the right target, because the rules differ. JSON requires double quotes and escapes control characters; JavaScript with single quotes escapes the single quote; a regular expression protects dots, asterisks, brackets, parentheses and slashes. The result does not include the quotes surrounding the string: you place them yourself. In the opposite direction, Unescape turns sequences into the characters they represent and warns if it finds an invalid sequence.
Escaping is not a security measure. It does not protect an SQL query, a web page or a system command from untrusted data; parameterized queries and context-specific escaping exist for that. This tool helps prepare literals correctly, not defend an application. It processes everything in your browser and does not keep the text.
A few examples help choose the target. A text with quotes and a line break, such as He said: "hello" and a second line, is escaped in JSON as He said: \"hello\"\nsecond line. The same text in JavaScript with single quotes only protects the single quote and line breaks. In a regular expression, a.b becomes a\.b so the dot matches only a period. After escaping, paste the result inside your quotes and run a minimal test: if the recovered value is identical to the original, the literal is correct. Escape only once: applying the same escaping twice produces doubled backslashes that will not match the original value when your code reads them back.
A practical check before using the result
Escape text containing quotes and line breaks for JSON and unescape it again: you must get exactly the original. For a regular expression, escape a.b and check in your code that the dot now matches only a literal dot.
Settings and limits
Paste text, choose the target (JSON, JavaScript or regular expression) and direction. Escaping protects quotes, backslashes and line breaks; for regular expressions, characters with special meaning. The result does not include the quotes surrounding the string.
Frequently asked questions
Does it protect SQL queries?
No. Escaping text for one language does not replace parameterized queries. Use this tool to prepare literals, not to defend an application.