String Escape and Unescape

Make a text safe to paste inside a JSON string, a URL, an HTML page or an SQL query, and turn it back.

How this is worked out

Each format has its own list of characters that must be written differently: quotes and line breaks in JSON and JavaScript, the characters < > & and quotes in HTML, reserved characters in a URL, a doubled single quote in SQL, a doubled double quote in CSV. For SQL, prefer parameterised queries to escaping by hand.

Frequently asked questions

Is escaping enough to prevent SQL injection?

No. Use parameterised queries. Escaping is for display and for quick one-off scripts.

Related tools: Url Encoder Decoder, Html Entity Encoder Decoder, Json Formatter.

Something not working on this page? Tell me through the Contact page: that is how I find out what is broken and fix it.