JSON Escape

Escape or unescape any string for use inside JSON, safely handling quotes, backslashes, newlines and special characters. No signup. Ideal for developers building JSON by hand.

Remove Ads
Remove Ads

Result

Result
Remove Ads

Share on Social Media:

A JSON escape tool turns plain text into a string that is safe to put inside JSON — and turns it back again. Paste text with quotes, backslashes, or line breaks, click Escape, and you get the escaped version ready to paste into your JSON. Click Unescape to turn an escaped string back into readable text. It is free, needs no account, and runs in your browser, so nothing you paste is uploaded.

On this page

  1. How to Escape a String for JSON Step by Step
  2. What JSON Escaping Is and Why It Is Necessary
  3. What Gets Escaped
  4. Worked Example
  5. Escaping With a Tool Versus Doing It by Hand
  6. Who Needs to Escape JSON
  7. Pro Tips for Safe JSON Strings
  8. Common JSON Escaping Mistakes to Avoid
  9. Related Tools You May Need Next
  10. Frequently Asked Questions

How to Escape a String for JSON Step by Step

  1. Paste your text. Paste or type it into the box above — it can contain quotes, backslashes, line breaks, or tabs.
  2. Click Escape. The escaped string appears below, ready to copy.
  3. Copy the result. Use Copy to Clipboard, then paste it inside the quotes of your JSON string.
  4. To unescape, paste an escaped string instead and click Unescape. The readable text appears below.
  5. Check the result. If Unescape shows "Invalid escaped string", the input is not a valid escaped string — check for a missing backslash or an unescaped quote.

What JSON Escaping Is and Why It Is Necessary

JSON strings cannot contain a raw double quote, a raw backslash, or a raw line break — those characters would end the string early or break the JSON. Escaping replaces each of them with a safe two-character sequence: a quote becomes \", a backslash becomes \\, and a newline becomes \n. The JSON parser reads those sequences and turns them back into the original characters. Without escaping, a single quote in a name or a line break in a message makes the whole JSON file invalid.

What Gets Escaped

This tool escapes exactly what the JSON standard requires — nothing extra:

CharacterBecomesWhy
Double quote "\"A raw quote would end the string
Backslash \\\A single backslash starts an escape sequence
Newline\nJSON strings cannot span lines
Carriage return\rSame — a line break inside a string
Tab\tA raw tab is not allowed in a JSON string
Backspace\bA control character
Form feed\fA control character
Other control characters (U+0000–U+001F)\u00XXFor example, U+0001 becomes \u0001

Two things are deliberately NOT escaped: the forward slash / and the single quote '. JSON does not require them to be escaped, so this tool leaves them as they are. If you see an unescaped / in the output, that is correct, not a bug.

Worked Example

Take this plain text (two lines, with quotes):

LineText
1He said "Hi!" and left.
2New line here.

Click Escape and you get exactly this — verified character for character:

LineText
1He said \"Hi!\" and left.\nNew line here.

The quote became \", the line break became \n, and everything else stayed the same. Paste that inside quotes — "He said \"Hi!\" and left.\nNew line here." — and it is valid JSON. Click Unescape on it and you get the original two lines back.

A second example — a Windows file path. The raw path C:\Users\sohel\notes.txt escapes to C:\\Users\\sohel\\notes.txt, because every backslash is doubled. Forgetting to escape a path is one of the most common reasons JSON breaks.

Escaping With a Tool Versus Doing It by Hand

Doing it by hand means finding every quote, backslash, and line break yourself and adding a backslash in front of each one. In a short string that is easy; in a long message with ten quotes and five line breaks, it is slow and easy to miss one — and one missed character invalidates the whole JSON file. A tool does the same job in one click and never misses a character. The only thing a tool cannot do is decide for you whether a string needs escaping at all: escape text once, before you put it into JSON, and unescape it when you read it back out.

Who Needs to Escape JSON

Developers. Embedding user text, messages, or file paths inside JSON for an API request or config file.

API testers. Pasting a message with quotes into a JSON request body without breaking it.

Data engineers. Moving text with line breaks into JSON logs or data files.

Students. Learning how JSON strings work and why a raw quote breaks them.

Support and QA teams. Reading an escaped string from a log file by unescaping it into plain text.

Pro Tips for Safe JSON Strings

Escape once, not twice. Escaping an already-escaped string doubles every backslash again (\\ becomes \\\\) and corrupts the text. If the output looks wrong, unescape it once and start again.

Escape before you assemble the JSON. Escape each piece of text first, then place it into the JSON structure — never try to escape a whole JSON document at once.

Check the error message. If Unescape says "Invalid escaped string", look for a lone backslash or a quote that was not escaped. Fix that one spot instead of retyping everything.

Remember the slash and single quote. The slash and single quote are not escaped, and that is correct — do not add backslashes to them by hand.

Test the result. Paste the escaped string into the JSON Validator to confirm the whole document is valid before you send it.

Keep the original. Copy the unescaped text somewhere safe before you escape it, so you can always go back.

Common JSON Escaping Mistakes to Avoid

Escaping twice. Running Escape on an already-escaped string doubles the backslashes — \\n in the output means a literal backslash followed by "n", not a newline.

Pasting multi-line text into JSON without escaping. A raw line break inside a JSON string is invalid; it must become \n.

Forgetting the backslash in a file path. A path such as C:\Users\sohel is invalid JSON; it must be C:\\Users\\sohel.

Adding a backslash before a forward slash. A backslash before a forward slash, as in \/, is allowed but unnecessary, and it makes the string harder to read.

Unescaping a plain string. Unescape expects an escaped string; feeding it plain text with a stray backslash gives the "Invalid escaped string" error.

Escaping the whole JSON document. Only the text inside the quotes needs escaping — escaping the braces and quotes of the JSON itself destroys it.

Expecting a result from an empty box. Clicking Escape or Unescape with nothing in the box shows Invalid Input once, with no browser bubble — there is no submit button to trigger one — and any previous result stays unchanged.

Expecting spaces to count as text. A box holding only spaces is not the same for both buttons: Escape shows a result — the spaces themselves, which look blank on the page — while Unescape trims the input first, so spaces alone show Invalid Input once, with no bubble, and any previous result stays unchanged.

Related Tools You May Need Next

JSON Formatter. Format and indent a JSON document so it is easy to read.

JSON Validator. Check whether a JSON document is valid before you use it.

JSON Minify. Remove whitespace from JSON to make it smaller.

JSON Beautifier. Pretty-print compact JSON with proper indentation.

JSON Viewer. View JSON as a collapsible tree.

JSON Editor. Edit JSON in a structured editor.

JSON to XML. Convert a JSON document into XML.

Frequently Asked Questions

How do I escape a JSON string?

Paste your text into the box above and click Escape. The escaped string appears below, ready to copy into your JSON. No signup is needed.

Is this JSON escape tool free?

Yes. It is completely free with no account and no usage limit, and it runs in your browser, so your text is never uploaded.

What characters does JSON escaping change?

Quotes become \", backslashes become \\, newlines become \n, tabs become \t, and other control characters become \u00XX. Forward slashes and single quotes are left unchanged, because JSON does not require them to be escaped.

How do I unescape a JSON string?

Paste the escaped string into the box and click Unescape. The readable text appears below. If the input is not a valid escaped string, the tool shows "Invalid escaped string".

Why is my JSON invalid after pasting text?

The most common reason is an unescaped quote, backslash, or line break in the pasted text. Escape the text first, then place it inside the JSON string.

Does escaping change my text?

No. Escaping only changes how the text is written inside JSON. When the JSON is parsed, the escape sequences turn back into the exact original characters.

Can I escape a string twice?

You can, but you should not. Escaping an already-escaped string doubles every backslash and changes the meaning of the text. Escape once, before the text goes into JSON.

What is the difference between escape and encode?

Escaping makes text safe inside a JSON string. Encoding (for example URL encoding or Base64) changes text for a different context, such as a web address. They solve different problems.

Is my text private?

Yes. The escaping happens in your browser with JavaScript. Nothing you paste is sent to a server or stored.

What does \u0001 mean in JSON?

It is the escaped form of the control character U+0001. JSON writes control characters as \u followed by four hex digits, so any character from U+0000 to U+001F appears in that form.