Text Escape/Unescape
Escape or unescape text for JSON, JavaScript, HTML and URL rules.
A raw quote or line break inside a string in code ends the string early. This tool replaces such characters following the rules of the format you choose, and with Live on it updates as you type. Everything runs in the page.
The input is It's "ok" followed by one Enter.
| Format | Result |
|---|---|
| JSON | It's \"ok\"\n |
| JavaScript | It\'s \"ok\"\n |
| HTML | It's "ok" (line break kept) |
| URL | It's%20%22ok%22%0A |
JSON strings only use double quotes, so the apostrophe is left alone. Korean characters change only in URL mode, to UTF-8 bytes such as %EA%B0%80. Pick the format by where the text will land: a JSON value needs JSON, a search term after ?q= needs URL. If contexts nest, such as JSON inside a URL parameter, escape the inner one first.
When unescaping as JavaScript, C:\new with single backslashes is treated as original text, so \n becomes a line break. \u{1F600} and \x41 are JavaScript syntax and will not decode as JSON. In URL mode only %20 is a space, not +. HTML escaping is safe for body text and attribute values, but not inside a <script> block. There is no SQL mode; use parameter binding.