What escaping is
Some characters have a special meaning in a given format. A double quote ends a JSON string, a less-than sign starts an HTML tag, and a single quote ends a SQL string. To use these characters as plain text, you add an escape: a backslash, an entity or a doubled quote. Unescaping reverses it. This tool does both for seven common formats.
How to use it
- Choose Escape or Unescape.
- Pick the format.
- Paste your text and copy the result.
What each format does
- JSON string: escapes quotes, backslashes and control characters such as new lines. Output has no outer quotes, ready to place inside a string.
- JavaScript string: escapes backslashes, both kinds of quotes, new lines, returns and tabs.
- HTML entities: turns & < > " and the apostrophe into & < > " and '. Escaping user input this way helps prevent cross-site scripting.
- XML: like HTML, with ' for the apostrophe.
- SQL string: doubles single quotes, as in O''Brien. Use parameterised queries in real code instead of building SQL strings.
- CSV field: wraps the field in quotes and doubles quotes inside it when it has a comma, quote or line break.
- Regex: puts a backslash before characters with special meaning, so text can be matched literally.
Example
JSON escaping of text with a quote and a backslash:
Plain text: He said "hello"\nPath: C:\temp
JSON escaped: He said \"hello\"\nPath: C:\\tempSecurity reminder
Escaping by hand is easy to get wrong. In applications, use the escaping built into your framework and parameterised database queries, not string concatenation. Use this tool to understand, test and debug escaped text.
Related tools
- URL Encoder / Decoder: Encode or decode URLs and query strings using percent-encoding, right in your browser.
- JSON Formatter & Validator: Format, validate, and beautify JSON with clear error messages for developers.
- Regex Tester & Generator: Test, validate, and debug regular expressions in real-time with our 100% client-side tool.
- Base64 Encoder & Decoder: Encode and decode Base64 strings for APIs, data transfer, and debugging.
