String Escaper

Escape special characters in strings for JavaScript, JSON, HTML, and more.

What is the Free String Escaper?

The free String Escaper escapes special characters in your text for five different contexts: JavaScript, HTML, JSON, Regex, and SQL. Click the appropriate mode button, paste your string, and get the properly escaped output to embed safely in code — no manual escaping or regex memory required.

  • Escape a user-submitted string before embedding it in a JavaScript template literal.
  • Escape HTML entities in text before injecting it into an HTML document.
  • Escape a string for insertion into a JSON value, handling quotes and backslashes.
  • Escape a search term before using it as a literal pattern in a regex.
  • Escape quotes and special characters in a SQL string literal for a query.

How to Use the Free String Escaper

  1. 1 Choose the target context using the mode buttons: JS, HTML, JSON, Regex, or SQL.
  2. 2 Paste or type the string you want to escape into the input area.
  3. 3 The escaped string appears instantly in the output.
  4. 4 Click Copy to paste the escaped result into your code.

Key Features

  • 🛡️
    Five escape contexts
    JavaScript, HTML, JSON, Regex, and SQL — the most common escaping scenarios covered.
  • Instant escaping
    Output updates live as you type or switch modes.
  • 📋
    One-click copy
    Grab the escaped string ready to paste into your code.
  • 🔒
    Private & local
    All escaping runs in your browser — nothing is uploaded.

Example Usage

Example Input
He said "Hello, World!" & it's great.
Example Output
He said \"Hello, World!\" & it\'s great.  (JS mode)
He said "Hello, World!" & it's great.  (HTML mode)

Frequently Asked Questions about the Free String Escaper

What is the free String Escaper?
Escape special characters in strings for JavaScript, JSON, HTML, and more.
Is the String Escaper free to use?
Yes, the String Escaper is completely free. No account, subscription, or signup is required — ever.
Does my data get uploaded anywhere?
No. The String Escaper runs entirely in your browser. Your data is never sent to any server.
Does it work offline?
Yes. Once the page has loaded, the tool works without an internet connection.
Which browsers are supported?
All modern browsers — Chrome, Firefox, Safari, and Edge. No plugins or extensions required.
What does JavaScript escaping handle?
It escapes backslashes, single quotes, double quotes, newlines, tabs, and carriage returns with their respective backslash sequences.
What does Regex escaping do?
It prefixes all regex metacharacters (. * + ? ^ $ { } [ ] | ( ) \) with a backslash so the string is treated as a literal pattern.
What does SQL escaping do?
It escapes single quotes by doubling them (the ANSI SQL standard) and escapes backslashes where required.

Related Free Text Tools