DevTools Logo

String Escape Utilities

String Escape Utilities

Escape and unescape strings for HTML, JavaScript, JSON, SQL, URL, and other formats

    Input & Settings

    4 of 10 types selected

    Examples

    Escape markup as HTML entities

    Input
    <div class="note">Tom & Jerry's</div>
    Output
    &lt;div class=&quot;note&quot;&gt;Tom &amp; Jerry&#x27;s&lt;/div&gt;

    Ampersands, angle brackets and both quote styles are replaced in the component's fixed order.

    Encode a URL component

    Input
    café / tea?
    Output
    caf%C3%A9%20%2F%20tea%3F

    encodeURIComponent converts the UTF-8 text and reserved separators into percent-encoded bytes.

    Encode UTF-8 text as Base64

    Input
    Hello, 世界
    Output
    SGVsbG8sIOS4lueVjA==

    The component converts the string to UTF-8 bytes before applying Base64 encoding.

    About this tool

    String Escape Utilities applies ten targeted encoders and decoders to one text input: HTML entities, JavaScript string escapes, JSON string content, SQL quote doubling, URL component encoding, CSV field quoting, XML entities, regular-expression metacharacters, Base64 and four-digit Unicode escapes. Select any combination and copy each result independently.

    Escape and Unescape modes use small format-specific transformations. JSON escaping delegates to JSON.stringify, URL mode uses encodeURIComponent and decodeURIComponent, CSV wraps fields containing commas, quotes or newlines, and the Base64 path converts UTF-8 text before calling browser Base64 APIs.

    Processing trims the entire input before conversion. The visible Batch mode and Preserve newlines switches are not currently applied by the processing function, and SQL escaping only doubles quotes—it does not parameterize or secure a query.

    How to use

    1. Choose a direction

      Select Escape to encode special characters or Unescape to reverse one of the supported encodings.

    2. Enter text and formats

      Paste text or load a sample, then enable the HTML, JavaScript, JSON, SQL, URL, CSV, XML, Regex, Base64 or Unicode result types you need.

    3. Process the text

      Click Escape Text or Unescape Text. The tool trims the outer whitespace and computes both directions for every selected format.

    4. Copy the appropriate result

      Review the separate result cards and copy only the encoding required by the destination context.

    Use cases

    Embedding text in markup

    Escape HTML or XML metacharacters before placing literal text into an appropriate text context.

    Preparing a URL query value

    Percent-encode one component before assembling it into a query string or path segment.

    Building test fixtures

    Produce JavaScript, JSON, CSV, Unicode or Base64 representations for deterministic parser and API tests.

    Escaping a literal regex fragment

    Backslash regex metacharacters before inserting user-supplied literal text into a larger expression.

    Common mistakes

    Mistake:Using SQL quote doubling instead of parameterized queries.

    Fix:Bind values through the database driver; use the SQL result only when you specifically need a quoted literal representation.

    Mistake:Selecting an encoding that does not match the destination context.

    Fix:Choose based on where the text will be inserted—HTML entities, JSON string content and URL components have different rules.

    Mistake:Expecting leading or trailing whitespace to survive.

    Fix:Account for the component's input.trim() call or use another tool when outer whitespace is significant.

    Mistake:Relying on Batch mode or Preserve newlines to change processing.

    Fix:Those switches currently do not affect the conversion; inspect the actual result and process lines separately when needed.

    Frequently asked questions

    References & standards