String Escaper / Unescaper
Developer utility to encode and decode strings for JSON, Java, HTML, XML, and URI contexts. Prevent syntax errors and injection vulnerabilities.
About
Data serialization requires strict adherence to syntax rules. A single unescaped quote in a JSON payload breaks the entire structure. Developers use string escaping to convert special characters into safe sequences. This process ensures that data passes through transport layers without being misinterpreted as executable code or delimiters. Security protocols rely on this transformation to prevent Cross Site Scripting (XSS) and SQL injection. Manual replacement is error-prone and slow. This tool automates the conversion across multiple standards including Java strings and Uniform Resource Identifiers. It guarantees that control characters like newlines and tabs are preserved correctly during the encoding process.
Formulas
The escaping process can be defined as a mapping function E that transforms a character sequence S based on a protocol P. For a single character c, the transformation logic follows strict conditional rules.
In URL encoding, specifically for the encodeURIComponent method, the set of unescaped characters U is limited to alphanumerics and specific symbols. The escape density ρ increases as the input contains more reserved characters.
A density ρ > 1 indicates that the string size has expanded due to encoding overhead (e.g. converting 1 byte into 3 bytes like %20).
Reference Data
| Character | Name | JSON / Java | HTML Entity | URL (UTF-8) | XML |
|---|---|---|---|---|---|
| " | Double Quote | \" | " | %22 | " |
| " | Single Quote | " (Java char \') | ' | %27 | ' |
| & | Ampersand | & | & | %26 | & |
| < | Less Than | < | < | %3C | < |
| > | Greater Than | > | > | %3E | > |
| \ | Backslash | \\ | \ | %5C | \ |
| LF | Line Feed | \n | %0A | ||
| CR | Carriage Return | \r | %0D | ||
| TAB | Horizontal Tab | \t | %09 | ||
| SPACE | Space | (non-breaking) | %20 | ||
| / | Forward Slash | \/ (optional) | / | %2F | / |
| BS | Backspace | \b | %08 | N/A |