Escape a string for JSON, for backslash-style languages (JS/C) or for the shell, and unescape it back. Handy when embedding text into code or config.
It turns quotes, backslashes and control characters into their escape sequences so the string is valid inside JSON.
It wraps the text in single quotes and safely encodes any embedded quote, so it survives as one literal argument.
For JSON mode the text must be a valid escaped string — an unbalanced quote or a bad escape sequence can't be decoded.