Home › All Tools ›

JS String Unescaper

Use JS String Unescaper online for free at FreeToolZones — no sign-up, no watermark.

Loading tool...

The JS String Unescaper on FreeToolZones takes an escaped JavaScript string and turns it back into the plain, readable text it represents. Escaped strings are everywhere in development: log files show line breaks as backslash-n, configuration values contain hexadecimal escapes, and code you copy from somewhere else is full of backslashes that obscure the real content. Reading that text in its escaped form is slow and error-prone, because your eye has to decode every escape sequence before it can understand the sentence. This tool does the decoding for you, in your browser, and shows you the actual characters the string holds.

Unescaping is the reverse of escaping, and the two tools form a natural pair. The escaper prepares text for code; the unescaper recovers text from code. You might use the unescaper to read a string you found in a script, to recover the original wording of a message stored with escapes, to inspect data that arrived in escaped form, or simply to check what a complicated literal actually contains. Whatever the reason, the workflow is the same: paste the escaped string, press Unescape, and read the result.

What Is the JS String Unescaper?

The JS String Unescaper is a free online tool that decodes JavaScript escape sequences into the characters they represent. It understands the standard short escapes: backslash-n becomes a line break, backslash-r becomes a carriage return, backslash-t becomes a tab, backslash-b becomes a backspace, backslash-f becomes a form feed, and backslash-v becomes a vertical tab. It understands backslash-zero as the null character. It understands hexadecimal escapes written as backslash-x followed by two hex digits, four-digit Unicode escapes written as backslash-u followed by four hex digits, and code point escapes written as backslash-u with a code point in braces, which can represent any Unicode character including emoji. It also understands escaped quotes, escaped backslashes, and line continuations, where a backslash at the end of a line means the string continues on the next line without adding a character.

Surrounding quotes are optional. If your input starts and ends with matching single quotes, double quotes, or backticks, the tool removes them before decoding, so you can paste a complete literal copied from code. If the input has no quotes, it is decoded as it stands. The tool also handles a partially quoted input in a tolerant way: if the input starts with a quote but does not end with the matching one, the opening quote is still treated as a quote and removed. This flexibility means you rarely have to tidy the input before pasting it.

One behavior deserves special attention. Template placeholders, the dollar sign and brace sequences used inside template literals to insert expressions, are left as plain text. The tool does not evaluate expressions, look up variables, or run any code, so a placeholder in the input appears unchanged in the output. That is a safety feature as much as a design choice: unescaping is a text operation, and it should never execute anything. The same reasoning applies to the whole tool: nothing you paste is run, compiled, or sent anywhere.

The output is shown with two statistics: the input character count and the decoded character count. The decoded count is usually smaller, because each escape sequence, which takes several characters to write, becomes a single character in the result. A Copy button lets you take the decoded text elsewhere. If the input cannot be decoded, the tool reports the problem instead of guessing, with a message that names the issue, such as an invalid hexadecimal escape and its position, an unterminated code point escape, a trailing backslash, or a legacy octal escape, which the tool explicitly does not support.

How to Use the JS String Unescaper

Decoding a string takes three steps.

  1. Paste the escaped string. Click in the box labeled Escaped string and paste the text you want to decode, with or without surrounding quotes. The hint below the box lists the escape forms the tool handles, so you can confirm at a glance that your input is covered. The box accepts multi-line input and long strings without preparation.
  2. Press Unescape. Click the Unescape button. If the box is empty, the tool asks you to enter an escaped string first. Otherwise the decoded text appears below, together with the input and decoded character counts. If the input contains an escape the tool cannot decode, an error message explains the problem instead.
  3. Copy the result. Press Copy to place the decoded text on your clipboard. The Load sample button fills the box with an example containing escaped quotes, a line break, a tab, and a Unicode escape for a snowman symbol, which is a good demonstration of several escape forms at once.

When an error appears, read it carefully before changing the input. An invalid hexadecimal escape usually means a backslash-x is followed by characters that are not hex digits, or by too few digits. An invalid Unicode escape means the same kind of problem after a backslash-u. A trailing backslash means the input ends with a lone backslash that has nothing after it. A legacy octal complaint means the input contains a backslash-zero followed by a digit, an old-style escape the tool refuses to guess at. Fixing the named problem and pressing Unescape again is usually all it takes.

It is also worth knowing what the tool does with an escaped character it does not specially recognize. Following JavaScript rules, an escape of an ordinary character simply yields that character: backslash followed by a letter that has no special meaning produces the letter itself. That behavior matches how the JavaScript engine treats such sequences in a string literal, so the decoded output reflects what the literal would actually hold at runtime.

Key Features of the JS String Unescaper

The feature set is focused on correct, predictable decoding.

Broad escape coverage

Short escapes, the null escape, hexadecimal escapes, four-digit Unicode escapes, and braced code point escapes are all decoded. Escaped quotes and backslashes are decoded, and line continuations are handled, including the carriage return plus line feed combination. This coverage matches the escape forms you will meet in real JavaScript code and in data derived from it.

Optional surrounding quotes

Complete literals can be pasted as they are, quotes included, and the tool strips the matching pair before decoding. Bare escaped text works too. You do not have to decide in advance which form your input takes, and you do not have to edit it before pasting.

Placeholders left untouched

Template placeholders stay as plain text, because decoding never evaluates anything. This keeps the tool safe for any input, including text that looks like code, and it keeps the output honest: what you see is the literal content of the string, not a computed value.

Honest error reporting

When decoding fails, the tool says why and, for position-specific problems, where. It never silently drops a bad escape or invents a replacement character. That honesty matters when you are inspecting data, because a silently wrong decode is worse than a clear error.

Counts and copy

The input and decoded character counts show how much the text shrank during decoding, which is a useful sanity check: a large drop usually means many escapes were decoded, while no drop means the input contained few or no escapes. The Copy button takes the decoded text to your clipboard in one click.

Practical Use Cases

Unescaping helps whenever escaped text stands between you and the real content. The situations below are the most common.

Reading strings found in code

When you open a script and find a long string full of escapes, perhaps a message, a template, or a chunk of data, pasting it here shows you what it actually says. Line breaks become real line breaks, tabs become real tabs, and Unicode escapes become the characters they represent. Reading the decoded version is faster and far less error-prone than decoding in your head.

Inspecting log output and stored data

Logs, databases, and data exports often store text with escapes, especially when the text contains line breaks or quotes. Unescaping a copied value reveals the original wording, including its line structure, which can be essential when you are diagnosing a formatting problem or verifying that stored data matches what a user typed.

Checking what a literal really contains

When a string behaves unexpectedly, the first question is what it actually holds. Pasting the literal here answers that question directly. You might discover a tab where you expected spaces, a carriage return hiding at the end of a line, or a Unicode character that looks identical to another one but has a different code point. Each of those discoveries points to a different fix.

Recovering text for reuse

If you need to reuse wording that currently exists only as an escaped literal, perhaps in an old script or a data file, unescaping it gives you clean text you can paste into a document, an editor, or a new string. The recovered text is the real content, free of the backslashes that were only there to make it valid code.

Learning escape sequences

For learners, the unescaper is a concrete way to see what each escape sequence means. Paste a literal containing several escape forms, decode it, and compare the input with the output side by side. The sample provided by the tool is designed for exactly this: it contains escaped quotes, a line break, a tab, and a Unicode escape, and the decoded result shows each one resolved.

Tips and Best Practices

  • Paste the whole literal, quotes and all. The tool handles surrounding quotes, so there is no need to strip them by hand. Pasting the complete literal also avoids accidentally dropping a character at the start or end.
  • Read error messages literally. They name the escape and the position. Fix that spot, not the whole string, and decode again.
  • Compare the character counts. If the decoded count barely changed, the input may have contained few escapes, or the escapes may be in a form the tool does not decode. Check the input against the supported list in the hint text.
  • Do not expect placeholders to resolve. A dollar-brace sequence stays as text. If you need the value of an expression, you need to run the code, not decode the string.
  • Pair with the escaper for round trips. Decode with this tool, edit the plain text, then re-escape with the JS String Escaper to get a fresh literal. That round trip is the safe way to edit escaped content.
  • Watch for invisible characters in the output. Decoded text may contain tabs, carriage returns, or null characters that are hard to see. If the output behaves oddly when pasted elsewhere, suspect an invisible character and inspect the escapes in the original input.

Limitations

The unescaper decodes escape sequences and nothing else. It does not evaluate expressions, resolve placeholders, or run code, so a template literal containing an expression will decode to text that still contains the expression source, not its value. It does not support legacy octal escapes: a backslash-zero followed by a digit is reported as an error rather than decoded, because octal escapes are ambiguous and forbidden in strict mode. It does not decode HTML entities, URL percent-encoding, or other escaping schemes; those belong to the HTML entity tool and the URL tools on this site.

The tool also decodes the whole input as one string. It does not split input containing several literals, and it does not understand the code around a literal, so pasting an entire script will decode backslash sequences wherever they appear, including ones that are not part of a string. For best results, paste a single literal or a single escaped value at a time. Finally, like the other tools here, it handles one input at a time in the browser, so bulk decoding of many values is better done with a script.

Frequently Asked Questions

Do I need to include the quotes?

No. Quotes are optional. If the input starts and ends with matching quotes or backticks, they are removed before decoding. If there are no quotes, the input is decoded as it stands. Either form works.

What escapes does the tool understand?

It handles the short escapes for line break, carriage return, tab, backspace, form feed, and vertical tab, the null escape, escaped quotes and backslashes, line continuations, hexadecimal escapes, four-digit Unicode escapes, and braced code point escapes. The hint under the input box lists the main forms.

Why does my input produce an error about octal escapes?

Legacy octal escapes, where a backslash is followed by octal digits, are not supported, because they are ambiguous and disallowed in strict mode. The tool reports them as an error instead of guessing. Rewrite the value using a hexadecimal or Unicode escape.

Why is a placeholder still in the output?

Template placeholders are left as plain text because the tool never evaluates code. Decoding shows the literal content of the string. To see a placeholder value, you must run the code with the variables defined.

Can the tool decode HTML entities or percent-encoding?

No. Those are different encoding schemes. Use the JS HTML Entity Tool for HTML entities and the JS URL Decoder for percent-encoded text.

Is my input uploaded anywhere?

No. Decoding runs entirely in your browser, and nothing is sent to a server.

Related Tools

These tools cover the matching encoding operations and the other contexts where text needs converting.

  • JS String Escaper – turn plain text into a valid JavaScript string literal with quotes included.
  • JS HTML Entity Tool – encode and decode HTML entities when text is destined for a web page.
  • JS URL Decoder – decode percent-encoded text back to its original characters.
  • JavaScript Validator – check the syntax of code that contains the literal you decoded.
  • JS Snippet Tester – run code and print a string to see its runtime value directly.

Browse More Tools