Use Cases
- Preparing strings for JSON that contain newlines or quotes
- Escaping user input for use in string literals
- Debugging escaped strings by converting them back to readable form
- Copying text from code that contains escape sequences
- Working with shell scripts where quotes and backslashes need escaping
- Preparing regex patterns that contain special characters
How It Works
Escape Mode (Default)
Converts these characters to escaped sequences:\→\\(backslash must be escaped first)\n(newline) →\\n\r(carriage return) →\\r\t(tab) →\\t"→\\"'→\\'
Unescape Mode
Reverses the process, converting escape sequences back to their literal characters.The order of operations matters: when escaping, backslashes are replaced first to avoid double-escaping. When unescaping, backslashes are replaced last.
Input Format
Escape: Plain text with special charactersOutput Format
Escape Output:Examples
Technical Details
Located in
lib/tools/engine.ts:469-470escapeBackslash(engine.ts:105-113): Replaces special characters with escape sequencesunescapeBackslash(engine.ts:115-123): Converts escape sequences back to characters
Supported Escape Sequences
| Character | Escape Sequence | Description |
|---|---|---|
\ | \\ | Backslash |
| Newline | \n | Line feed (LF) |
| Carriage return | \r | CR character |
| Tab | \t | Horizontal tab |
| Double quote | \" | Quote character |
| Single quote | \' | Apostrophe |
Performance
- Synchronous processing: Instant client-side conversion
- Sequential replacements: Uses
replaceAllfor efficiency - No regex parsing: Simple string replacement for maximum speed
Common Patterns
JSON String Preparation
When embedding multi-line text in JSON:Shell Script Escaping
For bash/zsh scripts with quotes:Programming Language Strings
For JavaScript, Python, Java, C++, etc.:Related Tools
- HTML Entity Encode/Decode - HTML entity encoding
- URL Encode/Decode - URL-safe encoding
- JSON Format/Validate - JSON formatting with escape handling
- String Inspector - Analyze escape sequences in strings