String Escape and Unescape

Escape and unescape strings for JavaScript and JSON online — free and instant.

About

About the String Escape and Unescape

Escapes text so it's safe to drop into a JavaScript or JSON string literal, or reverses an already-escaped string back into plain text.

Developers use it to turn a multi-line log message or code snippet into a single-line string literal they can paste into source code, and anyone debugging a payload uses it to turn an escaped string back into readable text. It's one of many free data tools on Toolapt, and like every tool here, it's free to use with no sign-up and no limit on how many times you run it.

Choose what to view about this tool

Guide

Using the String Escape and Unescape

  1. 1

    Step 1

    Type or paste your text into the Input box.

  2. 2

    Step 2

    Click "Escape" to turn it into a safe, single-line string literal.

  3. 3

    Step 3

    Or paste an already-escaped string and click "Unescape" to turn it back into plain text.

  4. 4

    Step 4

    Click "Copy" to copy the result, or "Clear" to start over.

  • Escapes line breaks, tabs, quotes and backslashes into their standard escape sequences
  • Produces output that's safe to paste directly into a JavaScript or JSON string literal
  • Unescapes a string back into its original, literal multi-line text
  • Clear error message if the text you try to unescape isn't validly escaped
  • One click to copy the result
  • Works entirely in your browser — nothing you type is sent to a server
  • Free to use, with no sign-up and no limit on how many times you run it

Developers

Developers use the String Escape tool for turning a multi-line log message or code snippet into a single-line string literal they can paste directly into source code.

API integrators

API integrators use the String Escape tool for preparing a value with quotes or line breaks so it's safe to embed inside a JSON request body.

QA engineers

QA engineers use the String Escape tool for unescaping a captured payload to read its real, literal content during debugging.

Students learning programming

Students learning programming use the String Escape tool for seeing exactly how special characters map to their escape sequences.

Examples

String Escape and Unescape examples

3 worked examples

01

Escaping quotes and a line break

A two-line string with quotes, Hello "World" / New line, escapes to Hello \"World\"\nNew line on one line.

02

Unescaping \n back to a real line break

Unescaping the literal text Line1\nLine2 turns the \n into a real line break, giving two separate lines.

03

Escaping backslashes

A Windows-style path like C:\Users\Name escapes each backslash to \\, giving C:\\Users\\Name.

FAQ

Frequently asked questions

Quick answers to common questions about the String Escape and Unescape.

What does the String Escape and Unescape tool do?

It escapes text into a safe, single-line JavaScript/JSON string literal, or reverses an escaped string back into plain text.

Is this tool free to use?

Yes. It's free, with no sign-up, no watermark and no limit on how many times you use it.

Is my text safe when I use this tool?

Yes. Escaping and unescaping both happen entirely on your own device using JSON.stringify and JSON.parse built into your browser — nothing you type is sent to a server.

What characters get escaped?

Line breaks become \n, tabs become \t, double quotes become \" , backslashes become \\ , and other control characters get their standard escape sequence, matching JavaScript/JSON string literal rules.

What happens if I try to unescape text that isn't validly escaped?

You'll see a clear error message — this is usually caused by an unescaped quote or a lone backslash in the text.

Is this the same as URL encoding?

No. This tool escapes characters for a JavaScript/JSON string literal (like \n and \"), which is different from URL percent-encoding (like %20). Use the URL Encoder for that instead.

Can I use this tool on my phone?

Yes. The page is fully responsive and works on mobile, tablet and desktop browsers alike.

Does this tool have any limitations?

It's built for typical text and log snippets. There's no artificial length limit, though very large inputs may take a moment longer.

Still have a question? Contact us

Report a problem

String Escape and Unescape

What went wrong?
    or paste a screenshot