Shell Escape
Free online shell escape tool. Escape strings for bash, shell and command-line use. Single quote, double quote and backslash modes. Prevent command injection. All processing is local and private.
How to Use Shell Escape
Enter Your String
Type or paste the string you want to escape. This could be a filename with spaces, a command argument with special characters, or any text that needs to be shell-safe.
Choose an Escape Mode
Select the escape style: single quotes (preserves everything literally), double quotes (allows variable expansion and escapes), or backslash (escapes each special character individually).
Copy the Escaped String
The escaped output is safe to use in shell commands, scripts, and Dockerfiles. Copy it directly into your terminal or shell script.
Escape Examples
| Input | Single Quotes |
|---|---|
| hello world | 'hello world' |
| it's working | 'it'\''s working' |
| $HOME/path | '$HOME/path' |
Frequently Asked Questions
Why do I need to escape shell strings?
The shell interprets certain characters specially: spaces separate arguments, $ starts variable expansion, backticks run commands, * expands to file names. If your string contains these characters and you don't escape it, the shell will interpret them, potentially executing unintended commands. Escaping tells the shell to treat these characters as literal text.
Single quotes vs double quotes vs backslash?
Single quotes ('...'): everything inside is literal — no character is special. Cannot contain single quotes themselves. Double quotes ("..."): most characters are literal, but $, `, !, and \ are still interpreted — useful when you need variable expansion. Backslash (\X): escapes the single following character. Use single quotes for most cases. Use backslash for individual characters.
What's the most common escape mistake?
Forgetting to escape spaces in filenames. A file named "my document.txt" needs to be passed as "my document.txt" (quoted) or my\ document.txt (backslash-escaped). Without escaping, the shell sees two separate arguments: "my" and "document.txt". This is the most common source of "file not found" errors in shell scripts.