String escape and unescape
Escape or unescape a string for JSON, JavaScript, HTML, URLs, CSV or regular expressions, with clear errors for broken escapes.
Questions
What does JSON escaping produce?
The inside of a JSON string, without the surrounding quotes: quotes, backslashes and control characters such as line breaks become \", \\ and \n.
Which regex characters are escaped?
The characters with special meaning in a JavaScript regular expression: \ ^ $ . * + ? ( ) [ ] { } | and the slash, so the text matches literally inside /.../ or new RegExp().
When does CSV add quotes?
When the value contains a comma, a double quote, a line break or leading or trailing spaces. Quotes inside are doubled, as RFC 4180 describes.