Tools › Encoding
String Escaper
Escape or unescape text as a JSON or JavaScript string, a single-quoted shell (zsh, bash) string, an AppleScript string, HTML or XML text, or a regular expression that matches it literally.
About this tool What it's for, how to use it and an example
What it's for
Make text safe to put inside code: quote it as a JSON string, a shell argument or an AppleScript string, turn it into HTML that displays literally, or into a regular expression that matches it exactly. Unescape reverses each of these.
For example, when you need to pass a file name with an apostrophe to a shell command, or drop a snippet of text into a JSON file, escape it here instead of fixing the quotes by hand.
How to use it
Paste the text, choose a format from As, and choose Escape or Unescape.
- JSON or JavaScript string adds double quotes and escapes quotes, backslashes and control characters.
- Shell (zsh, bash) single-quoted wraps the text in single quotes, which stops the shell expanding anything.
- AppleScript string adds double quotes and escapes
"and\. - HTML or XML text replaces
&,<,>and quotes with entities. - Regular expression puts a backslash before every character that has a special meaning in a regex.
Example
Paste this:
It's "done"
As JSON or JavaScript string, it becomes "It's \"done\"". As Shell, it becomes 'It'\''s "done"', the
standard way to put a single quote inside a single-quoted shell string. As HTML or XML text, it becomes
It's "done".
Good to know
Unescaping HTML decodes every entity, including named ones like é. The regular expression form is for JavaScript-style regexes; other flavours mostly agree, but check unusual characters.
Private: this tool runs in your browser. Nothing you type, paste or choose leaves this page.
Saved you a few minutes? Say thanks with a coffee.
Something wrong with this tool, or missing from it? Report a bug or suggest a feature.