String Escape/Unescape
Escape and unescape strings for JSON, JavaScript, HTML, and SQL. Handles special characters, backslashes, quotes, newlines, and Unicode escape sequences instantly.
How to use the string escape/unescape
Pick the target context (JSON, JavaScript, HTML, SQL). Edit the left side to escape, the right side to unescape.
Formula & explanation
JSON: uses JSON.stringify rules. JS: backslash-escapes quotes, backslash, and control chars. HTML: replaces &<>"' with named entities. SQL: doubles single quotes (the standard literal-string escape).
Examples
JSON: She said "hi" becomes She said \"hi\". SQL: it's becomes it''s (single quotes doubled).
Frequently asked questions
- When should I use HTML escaping vs JSON escaping?
- Use HTML escaping when inserting user-supplied text into an HTML page to prevent XSS. Use JSON escaping when embedding strings inside JSON payloads or configuration files.
- Why does SQL escaping only double single quotes?
- In standard SQL, string literals are delimited by single quotes, and a literal single quote inside a string is represented by two consecutive single quotes (''). This is defined by the SQL standard (ISO 9075).
- What is the difference between JS and JSON escaping?
- JSON escaping is a strict subset: it always uses double quotes and only escapes what the JSON spec requires. JS escaping is more permissive — it handles both single and double quotes and the same control characters.
- Does this tool send my text anywhere?
- No. All escaping and unescaping happens entirely in your browser with no data sent to any server.
Related developer tools tools
- JSON DiffCompare two JSON values semantically. Ignores key order; shows added, removed, and changed fields with their JSONPath — great for diffing API responses and config files.
- HTML Entities EncoderEncode text to HTML entities and decode entities back to text. Converts angle brackets, ampersands, quotes, and other special characters to safe equivalents for use in HTML templates and CMS workflows.
- JSON FormatterPretty-print, minify, and validate JSON. Detects syntax errors with line numbers and supports nested structures of any depth.
- XML to JSON ConverterConvert XML to JSON for legacy API integration, SOAP responses, and config migration. Handles attributes, namespaces, and text content.
- SQL FormatterPretty-print and format SQL for any major dialect — MySQL, PostgreSQL, SQLite, T-SQL, and more. Normalizes indentation, keywords, and spacing for readable, consistent queries.
- HTML EditorWrite HTML with live preview side-by-side. Syntax-highlighted editor with formatted source view — useful for testing snippets, email templates, or quick mockups in your browser.