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
- Paste your raw string into the box.
- Pick the target context, such as JSON, HTML or regex.
- 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
JSON Escape / Unescape
Escape a string so it is safe inside JSON, or unescape JSON escape sequences back to plain text. Handles quotes, newlines, tabs and unicode. Free and private.
HTML Entity Encoder
Encode text to HTML entities online. Escape &, <, >, " and ' so markup renders safely, with an option to convert non-ASCII characters too. Free and private.
URL Encoder
Encode or decode URLs and query strings online. Percent-encode a value, escape a full URL, or decode back to plain text. Free, fast and private.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
ASCII Table
Full ASCII table for all 128 codes with decimal, hex, octal and binary values, character names and descriptions. Search by code, hex or character.
Aspect Ratio Box Generator
Generate CSS for a responsive aspect-ratio container. Use the modern aspect-ratio property or the padding-top fallback, then copy the ready code.