Text Escape / Unescape
Escape or unescape strings for JavaScript, HTML, URL encoding, and JSON.
Escaping and Unescaping Notes
Escaping protects literal text when inserted into formats like JSON, HTML, or shell commands where special characters have meaning.
- Escape before embedding user text into templates or structured payloads.
- Unescape output when debugging logs copied from encoded contexts.
- Choose the correct mode for the target format to avoid double escaping.
About Escape Characters
An escape character is a character that invokes an alternative interpretation on the characters that follow it in a sequence. In many programming languages the backslash serves as the escape character, allowing newlines, tabs, quotation marks, and other special characters to appear inside string literals. Escape sequences are essential when special characters must appear in a context that would otherwise interpret them differently.
Common Escape Sequences
In JavaScript and JSON a backslash followed by n represents a newline, t represents a horizontal tab, and a doubled backslash represents a literal backslash character. HTML escaping converts angle brackets and ampersands into their named entity equivalents. URL encoding replaces unsafe characters with a percent sign and their hexadecimal byte value, making them safe to include in query strings and path segments.