Developer

String Escape Converter

Escape a string so it's safe inside a JSON or JavaScript literal — newlines, tabs, quotes, backslashes, \\uXXXX — or flip the toggle to unescape, all in your browser.

Direction
Escaped
Hello,\t\"world\"\nLine two — café ☕

Escaping turns real newlines, tabs, quotes and control characters into their backslash forms (\n, \t, \", \uXXXX) so the text is safe to drop inside a JSON or JavaScript string literal. Unescaping does the reverse.

How it works

Pick a direction with the toggle. In escape mode the tool scans your text and swaps out anything that would break a string literal: a real newline becomes \n, a tab becomes \t, a double quote becomes \", a backslash becomes \\, and any other control character becomes a \uXXXX code point.

In unescape mode it does the reverse, reading those backslash sequences and rebuilding the original characters — including \uXXXX and \xXX hex escapes. Paste an escaped blob you copied from a log or a JSON field and get the human-readable text back.

The escape output is designed to drop straight into a JSON string or a JavaScript double-quoted string without further fiddling. If you're unescaping and hit a malformed sequence like a stray backslash or a bad \u code, the tool tells you what went wrong instead of guessing.

Frequently asked questions

Is the escaped output valid inside JSON?

Yes. It escapes exactly the characters JSON requires — quotes, backslashes, and control characters — using \n, \t, and \uXXXX forms, so you can paste the result between double quotes in a JSON document and it'll parse.

Does it handle Unicode and emoji?

Printable Unicode like accented letters or emoji is left as-is, which is valid in both JSON and modern JavaScript source. Only control characters below the printable range get turned into \uXXXX escapes.

Why did unescaping show an error?

Because the input had a backslash sequence it couldn't make sense of — a lone backslash at the end, or a \u not followed by four hex digits, for example. Fix that sequence and it'll convert cleanly; nothing crashes in the meantime.