String Escape / Unescape

Escape or unescape a string for JavaScript, Java, C#, JSON, CSV, or SQL right in your browser.

Loading tool…

String Escape / UnescapeString Escape converts raw text into a safe string literal for a target language or format, and back again. Pick a context — JavaScript, Java, C#, JSON, CSV, or SQL — choose Escape or Unescape, and the result updates instantly. Every conversion runs entirely in your browser, so nothing you paste is ever sent to a server.

What is String Escape / Unescape?

String Escape / Unescape is a free in-browser utility that turns plain text into a safe string literal for code or data, and turns escaped literals back into readable text. Developers reach for it when they need to paste a multi-line value, a path with backslashes, or text containing quotes into source code without breaking the syntax. The context Select covers six common targets: JavaScript (escapes backslashes, double, single and backtick quotes, newlines, tabs and control bytes), Java and C# and JSON (backslash escapes plus \uXXXX for control characters), CSV (RFC 4180 quoting — wraps a field in double quotes and doubles inner quotes when it contains a comma, quote, or line break), and SQL (doubles the single quote so a string literal stays intact). The Escape / Unescape segmented control flips the direction: Escape produces the literal, Unescape decodes \n, \t, \uXXXX, doubled quotes, and wrapping quotes back to the original. Because the widget renders only with JavaScript, this text is the indexable description: escape a string for JS or SQL, unescape a JSON value, or prepare a CSV field.

How to use String Escape / Unescape

  1. Paste or type your text into the Input box.
  2. Open the settings panel and pick a context from the Context dropdown: JavaScript, Java, C#, JSON, CSV, or SQL.
  3. Choose Escape to produce a safe literal, or Unescape to decode an escaped string back to plain text.
  4. Read the converted result in the Output block — it updates automatically as you type.
  5. Click Copy to put the result on your clipboard, or Clear to reset the input.

Examples

Escape a path for a JavaScript string

Input

C:\Users\me\file.txt

Output

C:\\Users\\me\\file.txt

Escape a field for CSV

Input

Smith, John

Output

"Smith, John"

Escape a value for SQL

Input

O'Brien

Output

O''Brien

Frequently asked questions

What is the difference between the contexts?
JavaScript, Java, C#, and JSON use backslash escapes — backslash, quotes, newline (\n), tab (\t) and so on, with control bytes written as \uXXXX (JavaScript also handles single quotes and backticks). CSV follows RFC 4180: a field is wrapped in double quotes and inner quotes are doubled only when it contains a comma, quote, or line break. SQL doubles the single quote ('' ) so the string literal stays valid.
What does Unescape do?
Unescape reverses the process. For the backslash contexts it decodes \n, \r, \t, \uXXXX, \xXX and escaped quotes back to their real characters. For CSV it strips the surrounding quotes and turns doubled quotes back into one. For SQL it turns '' back into a single quote and removes wrapping quotes.
Does it handle Unicode and emoji?
Yes. Text is processed by code point, so accented letters, CJK characters, and emoji pass through unchanged when escaping. Unescape understands \uXXXX sequences and converts them back to the matching character.
Is my text uploaded to a server?
No. The whole conversion runs 100% client-side in your browser using built-in JavaScript string functions. Nothing you paste is uploaded, stored, or sent anywhere, so you can safely escape secrets, queries, or private data.

Related tools