{ String Escape/Unescape }

// escape & unescape strings for any format

Escape and unescape strings for JavaScript, JSON, HTML, URL, CSS, and regex formats instantly. Browser-based, free, no sign-up required.

FORMAT
MODE
0 characters

Ready to process

Select format, choose mode, then click Process

HOW TO USE

  1. 01
    Choose a format

    Select JS, JSON, HTML, URL, CSS, or Regex from the format tabs.

  2. 02
    Select mode

    Pick Escape to encode special characters, or Unescape to decode them back.

  3. 03
    Paste & process

    Paste your string, click Process, then copy the result with one click.

FEATURES

JavaScript / ES6 JSON strings HTML entities URL encoding CSS escaping Regex quoting Instant output 100% browser-side

USE CASES

  • 🔧 Sanitize user input for embedding in JS
  • 🔧 Prepare strings for JSON payloads
  • 🔧 Encode special characters for safe HTML output
  • 🔧 Build URL query strings correctly
  • 🔧 Create safe CSS content strings
  • 🔧 Escape metacharacters in regex patterns

WHAT IS THIS?

String escaping converts special characters into safe representations for a given context — preventing syntax errors, injection attacks, and encoding bugs. This tool handles six common formats used in web development every day.

RELATED TOOLS

FREQUENTLY ASKED QUESTIONS

What is string escaping?

String escaping is the process of converting special characters into sequences that are safe within a particular context — for example, turning a double-quote " into \" in JavaScript so it doesn't break a string literal.

What's the difference between JS and JSON escaping?

JavaScript string escaping uses backslash sequences and handles a wider range of control characters. JSON escaping is a strict subset — it only allows specific escape sequences defined in the JSON spec, such as \n, \t, \", and \\.

When should I use URL encoding?

Use URL encoding (also called percent-encoding) whenever you embed arbitrary text into a URL — in query parameters, path segments, or form submissions. Characters like spaces, &, and = have special meaning in URLs and must be encoded to avoid breaking the structure.

Why escape HTML strings?

HTML escaping converts characters like <, >, and & into their entity equivalents so browsers render them as literal text rather than markup. This is critical for preventing cross-site scripting (XSS) attacks when displaying user-supplied content.

What does CSS escaping do?

CSS escaping converts characters that have special meaning in CSS selectors or content values into their Unicode escape form (\XXXXXX). This is useful when dynamically building CSS selectors from user data that may contain spaces, dots, or brackets.

Is my data sent to a server?

No. All processing happens entirely in your browser via JavaScript. Your strings are never transmitted to any server, ensuring complete privacy for sensitive content like credentials, API keys, or personal data.

String Escape & Unescape — Complete Online Tool

Whether you're embedding text in a JavaScript string, building a URL query parameter, inserting HTML content dynamically, or writing a regular expression pattern, correct string escaping is fundamental to writing safe, bug-free code. This free, browser-based tool handles the six most common escaping formats used in modern web development — instantly, privately, and without requiring any account or installation.

Why Does String Escaping Matter?

Special characters carry meaning in every language and format. A double-quote inside a JavaScript string literal breaks the syntax. An ampersand inside HTML text gets misinterpreted as the start of an entity. A question mark inside a URL query value confuses the parser. Without proper escaping, these characters cause bugs ranging from minor display glitches to critical security vulnerabilities like SQL injection or cross-site scripting (XSS).

String unescaping is the reverse — converting encoded representations back into their original form. This is equally important when reading data from APIs, log files, databases, or configuration files that store escaped strings.

JavaScript String Escaping

JavaScript string escaping handles the backslash sequences defined in the ECMAScript specification. Characters like newlines (\n), carriage returns (\r), tabs (\t), backslashes (\\), and quote characters (\", \') are all escaped with a preceding backslash. Null bytes and other control characters in the range \x00\x1f are also escaped to prevent injection into script contexts. Use this format when building dynamic JavaScript code, template literals, or embedding text in JSON-free JS configurations.

JSON String Escaping

JSON escaping follows the strict rules defined in RFC 8259. Only specific sequences are valid: \", \\, \/, \b, \f, \n, \r, \t, and \uXXXX for Unicode code points. This tool produces output that is valid inside a JSON string value — useful for constructing JSON payloads manually, debugging REST API requests, or preparing data for storage in JSON-based databases.

HTML Entity Escaping

HTML entity escaping converts the five characters that have special significance in HTML markup: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot;, and ' becomes &#039;. This is essential whenever you're rendering user-generated content, dynamic text, or data from external sources inside an HTML page. Failing to escape HTML properly is one of the most common causes of XSS vulnerabilities in web applications.

HTML unescaping reverses this process — converting entity references like &eacute; or &#233; back to their original characters. This is useful when parsing HTML, working with CMS-generated content, or processing data scraped from web pages.

URL Encoding (Percent-Encoding)

URL encoding, formally known as percent-encoding, replaces characters that are not allowed or have reserved meaning in URLs with a percent sign followed by two hexadecimal digits representing the character's byte value. Spaces become %20, the plus sign becomes %2B, slashes become %2F, and so on. This tool uses rawurlencode semantics, which encodes all characters except unreserved ones — compliant with RFC 3986. Use URL encoding for query parameters, path segments, form data, and any string that will become part of a URL.

CSS String Escaping

CSS escaping converts non-alphanumeric characters into their Unicode escape form (\XXXXXX) as defined in the CSS Syntax specification. This is particularly useful when building CSS selectors programmatically — for instance, if you need to target an element whose ID contains dots, spaces, or hash symbols. The CSS escape format ensures these characters are treated as literal parts of identifiers rather than selector syntax.

Regex Character Escaping

Regular expressions use many metacharacters — ., *, +, ?, (, ), [, ], {, }, ^, $, |, \ — to define patterns. When you want to match one of these characters literally, it must be escaped with a backslash. This tool uses PHP's preg_quote() to escape all regex metacharacters, producing a safe pattern fragment you can embed in any regex.

Client-Side Processing — Complete Privacy

All conversions in this tool happen entirely inside your browser using JavaScript. No data is sent to any server at any point. This means you can safely paste sensitive strings — API keys, passwords, private messages, confidential data — without any risk of interception or logging. The tool works offline once the page is loaded.

Tips for Developers