Escape/Unescape Tool
Escape and unescape strings between multiple formats
Escape/Unescape Documentation
What is Character Escaping?
Character escaping is the process of converting special characters into escape sequences for safe use in specific contexts. For example, in a JavaScript string, double quotes need to be written as \" to be represented correctly.
Supported Formats
JavaScript Escape
Escape special characters in JavaScript strings, including quotes, newlines, tabs, etc.
JSON Escape
Convert strings to valid JSON string format, handling double quotes and control characters.
HTML Escape
Convert HTML special characters to HTML entities to prevent XSS attacks.
XML Escape
Convert XML special characters to XML entities to ensure XML document validity.
CSV Escape
Properly handle commas, quotes, and newlines in CSV format.
SQL Escape
Escape single quotes in SQL strings to prevent SQL injection attacks.
Regular Expression Escape
Escape special characters in regular expressions to match them literally.
C String Escape
Escape special characters in C/C++ strings, including octal and hexadecimal sequences.
Java String Escape
Escape special characters in Java strings, including Unicode escape sequences.
Common Use Cases
- Embed strings containing special characters in code
- Generate valid JSON data
- Prevent HTML and SQL injection attacks
- Handle special characters in CSV files
- Create safe regular expression patterns
Escape Rules Reference
JavaScript/JSON Escape Rules
| Original Character | Escaped Sequence | Description |
|---|---|---|
| \ | \\ | Backslash itself |
| ' | \' | Single quote |
| " | \" | Double quote |
| LF | \n | Newline |
| CR | \r | Carriage return |
| TAB | \t | Tab |
| BS | \b | Backspace |
| FF | \f | Form feed |
| U+XXXX | \uXXXX | Unicode character (4 hex digits) |
HTML Escape Rules
| Original Character | Escaped Sequence | Description |
|---|---|---|
| < | < | Less than |
| > | > | Greater than |
| & | & | Ampersand |
| " | " | Double quote |
| ' | ' | Single quote |
| | Non-breaking space |
XML Escape Rules
| Original Character | Escaped Sequence | Description |
|---|---|---|
| < | < | Less than |
| > | > | Greater than |
| & | & | Ampersand |
| " | " | Double quote |
| ' | ' | Single quote/apostrophe |
CSV Escape Rules
| Original Character | Escaped Sequence | Description |
|---|---|---|
| " | "" | Wrap field in quotes and double the quote |
| , | "...," | Wrap field containing comma in quotes |
| LF/CR | "...\n" | Wrap field containing newline in quotes |
SQL Escape Rules
| Original Character | Escaped Sequence | Description |
|---|---|---|
| ' | '' | Double the single quote |
| \ | \\ | Double the backslash (MySQL mode) |
Regular Expression Escape Rules
| Original Character | Escaped Sequence | Description |
|---|---|---|
| \ | \\ | Escape backslash |
| . | \. | Escape any character match |
| * | \* | Escape zero or more |
| + | \+ | Escape one or more |
| ? | \? | Escape zero or one |
| ^ | \^ | Escape start of line anchor |
| $ | \$ | Escape end of line anchor |
| | | \| | Escape alternation operator |
| [ ] | \[ \] | Escape character class brackets |
| ( ) | \( \) | Escape grouping parentheses |
| { } | \{ \} | Escape quantifier braces |
C/C++ String Escape Rules
| Original Character | Escaped Sequence | Description |
|---|---|---|
| \ | \\ | Backslash itself |
| ' | \' | Single quote |
| " | \" | Double quote |
| NUL | \0 | Null character |
| BEL | \a | Alert/bell |
| LF | \n | Newline |
| CR | \r | Carriage return |
| TAB | \t | Tab |
| 0-377 | \nnn | Octal value (1-3 digits) |
| 00-FF | \xnn | Hexadecimal value (2 digits) |
Java String Escape Rules
| Original Character | Escaped Sequence | Description |
|---|---|---|
| \ | \\ | Backslash itself |
| ' | \' | Single quote |
| " | \" | Double quote |
| LF | \n | Newline |
| CR | \r | Carriage return |
| TAB | \t | Tab |
| BS | \b | Backspace |
| FF | \f | Form feed |
| 0-377 | \nnn | Octal value (1-3 digits) |
| U+XXXX | \uXXXX | Unicode character (4 hex digits) |
Related Tools
HTML Encoder/Decoder
Convert special characters to HTML entities with named, decimal, and hexadecimal formats to prevent XSS attacks
URL Encoder/Decoder
Encode and decode URLs to ensure compliance and usability
Base64 Encoder/Decoder
Quickly encode and decode Base64 strings, supporting both text and file conversion