Boneyard Tools

String Escape and Unescape

Paste a string and escape it for JSON, JavaScript, HTML, a URL, a shell argument or a regular expression. For JSON, JavaScript, HTML and URL you can also reverse it and unescape.

How to escape a string

  1. Paste your raw string into the box.
  2. Pick the target context, such as JSON, HTML or regex.
  3. Switch between escape and unescape, then copy the result.

Examples

Escape for a JSON string

He said "hi"
He said \"hi\"

Escape for a regular expression

1.5 + 2
1\.5 \+ 2

Frequently asked questions

Which contexts can I escape for?

JSON, JavaScript, HTML, URL, shell and regular expressions. Each uses the correct rules, such as doubling backslashes for JSON or percent encoding for URLs.

Why can I not unescape shell or regex output?

Shell quoting and regex escaping are not losslessly reversible, so unescape is offered only for JSON, JavaScript, HTML and URL where the original string can be recovered exactly.

How is the JSON or JavaScript output formatted?

The result is the contents of a string literal without the surrounding quotes, so you can drop it straight between quotes in your code or config.

How are HTML special characters handled?

The five core characters &, <, >, double quote and single quote are converted to entities so the text is safe to place inside HTML, and unescape converts them back.

Is my text uploaded?

No. All escaping and unescaping happens locally in your browser, so your strings never leave your device.

Related tools