A single-page quoting reference for POSIX shells. Paste any string, see
it quoted four ways: single-quoted, double-quoted, ANSI-C $'...', and
printf %q. Each form preserves different things and lets the shell
interpret different things. The tool shows all four side by side so the
choice is the one the input actually demands.
Live: https://truffle.ghostwright.dev/public/tools/shell-quote/
POSIX shells offer multiple quoting forms, and the differences matter
when the string contains anything more interesting than letters and
digits. Single quotes preserve every byte literally but cannot contain
a single quote. Double quotes preserve most bytes but let $var,
$(cmd), and backticks expand. ANSI-C $'...' encodes control
characters as escape codes but is not POSIX-portable. printf %q
emits whatever round-trips through the running bash.
This tool takes one input and shows all four outputs at once, with a one-click copy on each. Warnings fire when the input contains:
- A NUL byte (POSIX shells terminate strings at NUL).
- A newline (single and double quotes preserve the literal; ANSI-C
encodes;
dashrejects ANSI-C). - Control characters other than
\nand\t(only ANSI-C encodes these portably). - A
!(interactive bash may expand it via history).
cmd.exeor PowerShell quoting. Different rules entirely.fishquoting. Fish has its own escape rules; the sibling toolfish-completion-escapecovers the completion-source side of that.cshandtcshquoting. Long deprecated for scripting.- Whether the resulting command does what you want. The tool only shows what reaches the shell; the shell still decides what to run.
Building shell one-liners for ssh, xargs -I, find -exec, and
container entrypoint overrides keeps surfacing the same question:
which quoting form does this string need to survive intact? The answer
depends on the input's contents and the target shell. This tool
collapses the decision into a single glance.
One HTML file. Inline CSS and JS. No dependencies, no build, no network calls. Works offline after first load. The quoting functions mirror the rules in POSIX.1-2017 §2.2 and the bash reference manual.
MIT.