All tools

Bash Escape

Escape strings for bash single, double, or ANSI-C quotes.

Single quotes (literal, recommended)
'hello $USER, today'\''s "fish" cost $5.99
newline & special chars'
Double quotes (allows variable expansion)
"hello \$USER, today's \"fish\" cost \$5.99
newline & special chars"
ANSI-C ($'...' with escape sequences)
$'hello $USER, today\'s "fish" cost $5.99\nnewline & special chars'

Quick reference

  • Single quotes: literal, no expansion. Safest for arbitrary input.
  • Double quotes: $variable, $(command), and `backticks` expand. Useful if you want them.
  • $'...': ANSI-C - lets you embed \n, \t, \r, etc.
  • Suggested env var name: $HELLO

Single quotes are the safest. Anything between them is literal - even backslashes. Double quotes allow $variable, command substitution, and backslash escapes for $, \, ", `, and !. Use single quotes unless you need expansion.

About

Single quotes are literal (safest). Double quotes allow $variable and command substitution. ANSI-C quotes ($'...') support escape sequences like \n. The tool generates all three forms.

How to use

  1. Paste your string.
  2. Pick the quoting style.

FAQ

Which should I use?+

Single quotes by default - safest because nothing expands. Double quotes when you actually want $vars to expand. ANSI-C when you need newlines or tabs.