What you can do with String Escape & Unescape
- Escape quotes in string
- Unescape backslashes
How this text processing works
Escape and unescape strings across JSON, JavaScript, SQL, Regular Expressions, HTML, and Bash shell syntaxes.
Example input
Path: C:\Program Files\App
Regex: /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i
Query: SELECT * FROM users WHERE note = "O'Connor";Example output
Path: C:\\Program Files\\App\nRegex: /^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$/i\nQuery: SELECT * FROM users WHERE note = \"O'Connor\";Practical workflow
- Enter your raw text string in the input pane.
- Select JSON, JavaScript, SQL, Regular Expression, HTML, or Bash shell as the target syntax.
- Review the result for the selected syntax and its matching literal context.
- Copy it only into that context; use parameterized queries for database values.
Common use cases
- Embedding multiline text strings into JSON configuration properties.
- Escaping literal strings before injecting them into dynamic regular expressions.
- Preparing arguments for Bash shell command execution.
Important notes and limitations
- JSON and JavaScript modes escape quotes, backslashes, line breaks, control characters, and Unicode edge cases for double-quoted string literals. Input and generated output are each limited to 1,000,000 UTF-16 code units; escaping can expand text and reach the output limit first, with an on-page message. A paste that exceeds the input limit is rejected in full so the existing draft is preserved.
- HTML mode encodes five markup-sensitive characters and decodes a selected entity set. Bash unescape only reverses this tool’s own single-quoted output; it is not a shell parser. ANSI SQL preserves backslashes and doubles apostrophes. Use parameterized queries for production database values.
- Input is processed locally in the current tab and is not stored by this tool.
Multi-language string escaping CLI utilities
JSON escape string with jq
printf '%s' 'Line 1
Line 2 "Quote" Tab' | jq -Rs .Escapes newlines, double quotes, and control characters into valid JSON-escaped string literal format.
Shell-escape string with python shlex
python3 -c "import shlex; print(shlex.quote('File Name with Spaces; rm -rf /'))"Wraps strings in safe single quotes to prevent command injection when interpolating shell variables.
Escape sequence parsing & regex slash troubleshooting
SyntaxError: Unexpected token in JSON at position ... (unescaped backslash)
Cause: Windows file paths (C:\Users\...) pasted into JSON strings without escaping backslashes (C:\\Users\\...).
Solution: Escape all backslashes as '\\' before feeding path strings to JSON.parse() or REST API endpoints.
Regular expression character class escape collision
Cause: Passing strings containing regex metacharacters (., *, +, ?, [, ], (, ), {, }) to 'new RegExp()'.
Solution: Use RegExp.escape() or sanitize strings with 'str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')'.
Continue your workflow
- HTML Entities — escape characters specifically for HTML web display.
- Regex Tester — test and debug your regular expressions against live strings.
Frequently asked questions
Why do backslashes double when escaping strings for JSON?
In JSON syntax, a backslash is the escape character. To represent a literal backslash inside a string, JSON syntax requires a second backslash.
How does the Regular Expression escaper protect against syntax errors?
It prefixes regex metacharacters such as periods, quantifiers, anchors, braces, parentheses, pipes, square brackets, and backslashes so input characters are matched literally.
Does the SQL escaper replace parameterized database queries?
No. String escaping is a convenience utility for scripts and debugging. Production applications should always use parameterized queries and prepared statements.
How does the ANSI SQL option handle backslashes?
ANSI SQL treats backslashes as ordinary characters, so this option preserves them and doubles apostrophes. SQL dialect settings differ; use parameterized queries for values in application code.
Why can an escaped result reach its limit before the input does?
Escaping can replace one input character with several output characters, such as a control character becoming a six-character Unicode escape. Input and output are capped separately at 1,000,000 UTF-16 code units, and the tool shows a recoverable message when generated output reaches its cap.