Shell Quote Builder
Paste any text and get a shell word that expands back to exactly that text: the single-quoted form POSIX sh understands, plus the bare, double-quoted and bash ANSI-C forms when they are safe. Each one is read back by the page's own quote-removal parser, so you can see it reproduces the text. Switch to decoding to paste a quoted word and see the value quote removal produces. Everything runs in your browser; nothing is uploaded, stored or sent anywhere.
Result
POSIX sh — single quotesreads back exactly
not computed
Double quotesreads back exactly
not computed
Bare wordreads back exactly
not computed
ANSI-C $'…'reads back exactly
not computed
Forms that are not offered
Embedding through another shell
Two layers — ssh, su or sh -c
not computed
Three layers
not computed
- Characters
- not computedcode points, counting control characters
- UTF-8 bytes
- not computedwhat the program receives
- Single quotes
- not computedeach is written as a closed quote, an escaped quote and a reopened quote
- Quoting needed
- not computedwhether the text survives as a bare word
How this is worked out
- Quote the text to see the steps.
Value after quote removal
not computed
Canonical single-quoted formreads back exactly
not computed
Quoting the decoded value again gives this word; it is the form to paste into a script.
- Characters
- not computedafter the quotes were removed
- UTF-8 bytes
- not computedwhat the program receives
- Quoting used
- not computedsingle quotes, double quotes, backslash escapes or ANSI-C
- Round trip
- not computedthe canonical form read back again
How this is worked out
- Decode a word to see the steps.
Which characters the shell treats as special
| Character | Bare word | Inside double quotes |
|---|
What this does not do
- This page models quote removal only: no parameter expansion, command substitution, arithmetic expansion, pathname expansion, brace expansion, tilde expansion, aliases or here-documents.
- It never runs the text. Nothing is passed to a shell, executed, stored or sent anywhere.
- A shell word cannot contain a NUL byte, so text holding one is refused instead of quoted.
- A quoted trailing newline survives, but command substitution strips trailing newlines and a terminal may add or remove one when you paste.
- Which characters are special can differ in other shells, under other locales and inside [[ ]] or case patterns; the table follows POSIX sh and bash.
- The text is limited to 8192 characters here, and decoding reads one word at a time.