Escape - VBScript

VB Script Escape Command


The Escape function in VB Script is used to escape special characters in a string, making it safe for inclusion in URLs, HTML/XML attributes, or other contexts that require special character handling.



  • str: String variable containing the input string that needs escaping.




  • Escape URL query strings:

    Dim url = "" & Escape("my search query")
  • Escape HTML/XML attributes:

    Dim html = "<input type='text' value='" & Escape("user's name") & "'>"

Common Issues

  • Double Escaping: Be cautious of double-escaping strings that have already been escaped. Double escaping can break the intended functionality.

  • URL vs. HTML/XML Escaping: Different contexts require different escaping mechanisms. Use appropriate escaping methods based on the target context.


  • Combine with URL Encode/Decode: Use Escape with URLEncode and URLDecode to handle escaping and unescaping strings in various web-related contexts.
  • Escape XML/HTML Attributes: Ensure correct rendering and data integrity by escaping special characters in HTML/XML attributes using Escape.

Related Commands

  • URLEncode
  • URLDecode
  • Replace