String Escape & Unescape Tool

Make text safe to put inside code: escape quotes, new lines and special characters for your language, or decode escaped text back.

FreeNo sign-upPrivate — runs in your browser
0Input characters
0Output characters
0Escapes

How to use the String Escape Tool

  1. Choose escape or unescapeEscape turns text into a safe string literal; unescape turns \n, \" and \u codes back into real characters.
  2. Pick the formatJSON, JavaScript, Java/C#/C, Python, SQL, CSV, regular expressions or XML/HTML. For JavaScript, Python and SQL you can choose single or double quotes.
  3. Copy the resultOptionally escape all non-ASCII characters as \u codes and add the surrounding quotes, then copy.

Example

She said "Hello!" escaped for JSON becomes She said \"Hello!\", and a line break becomes \n. The sample needs 7 escapes.

For SQL, it's becomes it''s. For a regular expression, 50% (off) becomes 50% \(off\).

Frequently asked questions

What is the difference between JSON and JavaScript escaping?

JSON strings must use double quotes and allow only \" \\ \/ \b \f \n \r \t and \uXXXX. JavaScript also allows single quotes, \x codes and \u{…} for emoji, so it can escape a single quote instead.

Should I escape strings for SQL myself?

Doubling quotes is fine for a quick manual query, but in application code always use parameterised queries (prepared statements). They prevent SQL injection completely.

What does “Escape non-ASCII” do?

It writes every character outside basic English as a code, so é becomes \u00E9 and emoji become surrogate pairs like \uD83C\uDF89. This is useful for files or systems that only accept ASCII.

Popular posts from this blog

Character Counter

Speech to Text Online

Keyboard Tester