Shell Argument Escaper
Quote any string safely for POSIX sh/Bash/Zsh (single quotes), Bash ANSI-C $'…' or PowerShell – or parse quoted shell words back to their values.
19 characters · 19 bytes (UTF-8)
0 characters · 0 bytes (UTF-8)
Runs entirely in your browser. Your data is never uploaded.
What is Shell Escape?
Turns any text into a single shell argument that the shell passes on unchanged – quotes, $, backticks, spaces and newlines included. It supports POSIX shells, Bash/Zsh ANSI-C quoting and PowerShell, and can parse quoted words back.
How to use Shell Escape
- Choose Escape or Unescape.
- Select the Shell: POSIX sh/Bash/Zsh, Bash/Zsh ANSI-C or PowerShell.
- Optionally treat each line as a separate argument or always add quotes.
- Paste the value into Input and copy the quoted argument from Output.
Example
It's $HOME
'It'\''s $HOME'
When to use Shell Escape
Use it when building commands that contain file names, passwords or user input – in scripts, SSH commands, CI configs or documentation. Windows cmd.exe is not supported because it has no quoting that is safe for all inputs. Prefer passing argument arrays (e.g. execFile, subprocess.run([...])) over building shell strings in programs.
How Shell Escape works
POSIX mode wraps the text in single quotes, inside which nothing is special, and writes each ' as '\'' (close quote, escaped quote, reopen) – the same approach as Python's shlex.quote. Simple words made only of A–Z a–z 0–9 _ @ % + = : , . / - are left unquoted unless you ask for quotes. ANSI-C mode produces $'…' with \n, \t, \' and \xHH escapes, which shows control characters visibly. PowerShell mode uses single quotes and doubles every single quote (including typographic ‘ ’). Unescape mode parses words like the shell does (quotes, backslashes, $'…') without performing any expansion.
Common Use Cases
- Passing a file name with spaces or quotes to a command
- Embedding a JSON payload in a
curlcommand - Quoting arguments for
ssh host "command" - Understanding what a complex quoted command line actually passes
Security Note
Correct quoting prevents command injection only when the quoted value is used as one argument; it does not make an unsafe command safe.
FAQs
Why not just use double quotes?
Inside double quotes the shell still expands $VAR, backticks and \. Single quotes disable all expansion, which is why they are safe for arbitrary text.
What does '\'' mean?
It ends the single-quoted part, adds an escaped literal quote, and starts a new single-quoted part. The shell joins the pieces into one argument.
Is Windows cmd.exe supported?
No. cmd.exe has no quoting that reliably protects characters like % and ^ in every context. Use PowerShell mode or avoid the shell.