String Escaper
Escape special characters in strings for JavaScript, JSON, HTML, and more.
Free browser-based tool · Runs 100% on your device · Last updated
What is the 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 String Escaper
- 1 Choose the target context using the mode buttons: JS, HTML, JSON, Regex, or SQL.
- 2 Paste or type the string you want to escape into the input area.
- 3 The escaped string appears instantly in the output.
- 4 Click Copy to paste the escaped result into your code.
Key Features
- 🛡️ Five escape contextsJavaScript, HTML, JSON, Regex, and SQL — the most common escaping scenarios covered.
- ⚡ Instant escapingOutput updates live as you type or switch modes.
- 📋 One-click copyGrab the escaped string ready to paste into your code.
- 🔒 Private & localAll escaping runs in your browser — nothing is uploaded.
Example Usage
He said "Hello, World!" & it's great.
He said \"Hello, World!\" & it\'s great. (JS mode) He said "Hello, World!" & it's great. (HTML mode)
Frequently Asked Questions about the String Escaper
- What is the String Escaper?
- The String Escaper is a free online tool that lets you escape special characters in strings for JavaScript, JSON, HTML, and more. It runs entirely in your browser, so there is nothing to install and nothing is uploaded to a server.
- Is the String Escaper free?
- Yes — the String Escaper is completely free, with no account, subscription, signup, or usage limits.
- Is my data uploaded or stored?
- No. The String Escaper processes everything locally in your browser. Your input is never uploaded, saved, or shared with any server.
- Does the String Escaper work offline?
- Yes. Once the page has finished loading, the String Escaper works without an internet connection.
- Which browsers does the String Escaper work in?
- The String Escaper works in all modern browsers, including Chrome, Firefox, Safari, and Edge — no plugins or extensions needed.
- 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 Developer Utilities
Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal.
JSON Formatter
Format, validate, and beautify JSON data with syntax highlighting.
JSON Validator
Validate JSON syntax and get clear error messages for invalid JSON.
XML Formatter
Format and prettify XML code with proper indentation.
YAML Formatter
Format and validate YAML files with clear syntax error reporting.
Base64 Encoder / Decoder
Encode and decode Base64 strings instantly in your browser.