String Escape & Unescape
Escape and unescape strings for JavaScript, JSON, HTML, SQL, and regex. Handle special characters safely.
About this tool
Special characters in strings can cause syntax errors, security vulnerabilities, or unexpected behavior if not properly escaped. This tool handles escaping for multiple contexts.
JavaScript escaping: Backslash-escape characters that would break a JS string literal (\n, \t, \\, \', \").
JSON escaping: Escape a raw string so it can safely appear as a JSON string value. Handles all JSON escape sequences.
HTML escaping: Convert < > & " ' to HTML entities for safe display in HTML documents.
SQL escaping: Escape single quotes for SQL string literals (never use this as the sole protection — use parameterized queries).
RegEx escaping: Escape metacharacters so a string can be used as a literal pattern in a regular expression.
URL escaping: Same as URL encoding — see the URL Encoder/Decoder tool for full URL parsing.
Frequently Asked Questions
When do I need to escape a string?
What is a newline escape sequence?
Is SQL escaping safe for preventing SQL injection?
What characters need to be escaped in regex?
Related Tools
URL Encoder/Decoder
Encode and decode URLs and query strings. Parse URL components. Convert special characters to percent-encoding.
HTML Entity Codec
Encode and decode HTML entities. Convert special characters to &, <, > and decode them back.
Regex Tester
Test regular expressions with real-time match highlighting, named groups, and plain-English explanation of each part.
JSON Formatter
Format, validate, beautify, and minify JSON instantly. Syntax highlighting, error detection, and path copying. 100% client-side.