String Escape / Unescape

New

Escape strings for JS, HTML, CSS, JSON, regex, URL and shell.

How was your experience with this tool?

Found a bug? Missing a feature? Tell us — it takes 10 seconds.

See how it works

Watch a quick simulation of this tool in action — no file needed.

How to use String Escape / Unescape

Follow these steps — everything happens instantly in your browser.

  1. 1

    Step 1. Pick the context — JS, HTML, CSS, JSON, regex, URL or shell.

  2. 2

    Step 2. Toggle Escape or Unescape.

  3. 3

    Step 3. Type your input — output updates live.

  4. 4

    Step 4. Copy the result.

String Escape and Unescape for JSON, JavaScript, and CSV

What escaping actually does

Every programming language reserves a few characters as structural. In a double-quoted string, the double-quote character itself marks the end of the string, and the backslash starts an escape sequence. If your text contains either one, you cannot paste it raw — the parser will misread where the string ends and throw a syntax error.

Escaping replaces each structural character with a safe two-character sequence: a double-quote becomes backslash-quote, a backslash becomes double-backslash, a newline becomes backslash-n, and a tab becomes backslash-t. The parser then reads those sequences and reconstructs the original characters without ever mistaking them for structure.

This tool escapes a raw string for embedding in JSON, JavaScript, Java, C, or CSV, and it also unescapes — turning an escaped string back into its readable original.

Escape sequences by target format

Different targets escape slightly different characters:

| Character | JSON / JavaScript | CSV |

| --- | --- | --- |

| double quote | backslash then quote | doubled quote |

| backslash | double backslash | unchanged |

| newline | backslash-n | wrap field in quotes |

| tab | backslash-t | unchanged |

Note that CSV is the odd one out: it does not use backslash escaping at all. Instead it doubles a quote inside a quoted field and wraps any field containing a comma or newline in quotes. Choosing the wrong target is the most common cause of broken output.

How to use the tool

Paste your raw text into the input and choose Escape to produce a safe, embeddable string.

Pick the target format (JSON/JavaScript or CSV) so the correct rules are applied.

Choose Unescape to reverse an already-escaped string back into plain text.

Copy the result straight into your code, config file, or spreadsheet.

Verifying your escaped output

The fastest check is a round trip: escape your text, then unescape the result, and confirm it matches the original character-for-character. If it does not, the target format was wrong or the input contained a character the target does not handle.

For JSON specifically, paste the escaped value into a JSON validator wrapped in quotes. If it parses, the escaping is correct; if it reports an unexpected token, an inner quote or backslash was missed.

Common mistakes

Escaping for JSON but pasting into CSV (or vice versa). The rules do not overlap.

Double-escaping: running an already-escaped string through Escape again turns one backslash into two and corrupts the text on unescape.

Forgetting that forward slashes do not need escaping in JSON, even though some tools add a backslash before them.

Assuming newlines survive a copy-paste; a literal line break inside a JSON string must become the two characters backslash-n.

Where this is useful

Embedding a multi-line log message or file path into a JSON config or API request body.

Building a CSV export where cell values contain commas, quotes, or line breaks.

Pasting a Windows file path (full of backslashes) into a JavaScript string.

Debugging an API error caused by an unescaped quote in a request payload.

Frequently asked questions

Q: Does JSON escaping differ from JavaScript escaping?

A: They overlap almost completely for strings — quote, backslash, newline, tab. JavaScript additionally allows single-quoted strings and template literals, but the double-quoted rules are identical.

Q: Why does CSV double the quote instead of using a backslash?

A: CSV has no backslash escape. The convention is to wrap the field in quotes and represent an inner quote by doubling it.

Q: Is my text uploaded anywhere?

A: No. Escaping and unescaping run entirely in your browser.

Q: Can I escape an entire code file?

A: You can, but the intent is escaping string values for embedding. Escaping a whole file is valid but rarely what you want.

Escape your string now

Open the String Escape / Unescape tool. For related encoding tasks, see HTML Entities, URL Encode / Decode, or format data with the JSON Formatter.

Want the extended step-by-step tutorial? Read it here.

Why use this tool

Private by design

All processing happens locally in your browser. Open DevTools → Network and you'll see zero file uploads. Ever.

Instant

No upload wait, no queue, no server round-trip. Results appear the moment you drop a file.

Free & unlimited

No accounts, no watermarks, no daily caps. Use it as many times as you like, forever.

Works everywhere

Desktop, tablet or phone — every tool is responsive and installable as a PWA for offline use.

Frequently asked questions

Everything you might want to know about string escape / unescape.

❤️ This tool is free — forever.

Sharing it helps more people discover it, and ad revenue from visitors is what keeps it free. No accounts, no catch.

Want to learn more?

Read our complete String Escape / Unescape tutorial with tips, use cases, and FAQs.