Developer Tools· 4 min read

String Escape and Unescape for JSON, JavaScript, and CSV

Safely escape quotes, backslashes, and newlines for any language — or reverse an escaped string back to its raw form.

By EasyDevTools Team Last updated: 2026-08-24

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.

See it in action

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.

Need help using this tool?

Read our complete String Escape / Unescape tutorial for step-by-step guidance.

Ready to try the tool?

No accounts. No uploads. No limits. Start now.