Escape & Unescape String

Escape and unescape strings for JavaScript, HTML, URL, and Unicode with real-time conversion.

Advertisement

🔒

Your Privacy Matters

We don't store any of your data. All escaping/unescaping happens locally in your browser. Only query parameters are included if you decide to share the URL.

Input

Output

Advertisement

How to Use the Escape & Unescape Tool

The Escape & Unescape String tool is essential for developers working with different encoding formats. Simply paste your text into the input field, select the encoding mode (JavaScript, HTML, URL, or Unicode), and choose whether to escape or unescape. The conversion happens automatically in real-time with a 300ms debounce — no buttons to click.

JavaScript/JSON mode handles all special characters needed for valid JavaScript strings and JSON data: quotes are escaped as \", newlines become \n, tabs become \t, and backslashes are doubled. This is crucial when generating dynamic JavaScript code, embedding strings in JSON responses, or preparing data for JSON.stringify(). It prevents syntax errors and ensures your strings are properly formatted.

HTML Entities mode converts characters that have special meaning in HTML into their entity equivalents. Less-than becomes <, greater-than becomes >, ampersands become &, and quotes are converted to " or '. This is essential for displaying user-generated content safely in web pages and preventing XSS (Cross-Site Scripting) attacks. Always escape untrusted input before rendering it in HTML.

URL Encoding mode converts characters into percent-encoded format for safe transmission in URLs. Spaces become %20, special characters are converted to %XX format, and reserved characters are properly encoded. Use this when building query strings, encoding form data, or working with RESTful API endpoints that require URL-safe parameters.

Unicode Escape mode represents non-ASCII characters as \uXXXX escape sequences. This is useful when working with systems that only support ASCII, debugging character encoding issues, or ensuring compatibility with older tools and file formats. Modern development rarely requires this, but it's invaluable when dealing with legacy systems or inspecting encoded strings.

The Swap button makes it easy to reverse the process: it exchanges the input and output and toggles between escape and unescape modes. Use the Copy button to grab the converted output for pasting into your code, configuration files, or documentation. The Share button generates a URL with your conversion pre-filled, perfect for sharing examples with teammates or bookmarking common conversions.

Frequently Asked Questions

What does escaping a string mean?

Escaping a string means converting special characters into a format that can be safely used in code or data. For example, a newline character becomes \n in JavaScript, or a less-than sign becomes &lt; in HTML. This prevents syntax errors and security vulnerabilities like XSS attacks.

When should I use JavaScript/JSON escaping?

Use JavaScript escaping when embedding strings in JavaScript code or JSON data. This handles quotes, backslashes, newlines, tabs, and other control characters. It's essential for generating dynamic JavaScript code or preparing strings for JSON.stringify().

What's the difference between HTML escaping and URL encoding?

HTML escaping converts characters like <, >, &, and quotes into HTML entities (&lt;, &gt;, etc.) to display them as text in HTML. URL encoding converts characters into percent-encoded format (%20 for space) for safe transmission in URLs. They serve different purposes and aren't interchangeable.

When do I need Unicode escaping?

Unicode escaping is useful when you need to represent non-ASCII characters in ASCII-only environments, like older systems or certain file formats. It converts characters like 'é' into \u00e9. Modern systems usually support UTF-8, making this less common, but it's still useful for debugging or working with legacy code.

Can I reverse the escaping process?

Yes! Toggle between Escape and Unescape modes to convert in either direction. The tool automatically handles the conversion. You can also use the Swap button to exchange input and output, making it easy to test both directions quickly.

Is my data secure when using this tool?

Absolutely. All escaping and unescaping happens entirely in your browser using JavaScript. Your strings are never sent to any server. This makes it safe for sensitive data like API keys, passwords, or private messages. We don't store any of your data.