Skip to content

JSON Escape

Escape a string for use inside JSON.

Input
Output

No result

About JSON Escape

JSON Escape takes a line of text and turns it into the escaped form it would need inside a JSON string. A double quote becomes a backslash-quote, a backslash is doubled, a newline becomes the two characters backslash-n, and a tab becomes backslash-t. The tool works live, recalculating on every keystroke, and the sample that starts loaded - a short quotation with a line break in it - shows each of the main rules firing at once.

The mechanics are worth knowing: the text is passed through the same escaping a JSON serializer applies to a string, and the surrounding quotes are then stripped, so what you get is the payload ready to be wrapped in your own quotes. Characters below the printable range come back as backslash-u escapes, while accented letters and characters from other scripts pass through unchanged, because a modern JSON serializer leaves them alone.

The page fills one narrow role and refuses to pretend at a wider one. It escapes for a string value; it does not validate a document, it does not escape a whole object while preserving its structure, and it runs one way only - the companion JSON Unescape tool does the reverse, and feeding it already-escaped text will happily double every backslash in sight.

How to use JSON Escape

  1. 1 Paste the text into the panel - the sample shows a quoted phrase with a newline in it.
  2. 2 Read the live output, where quotes, backslashes and control characters have been escaped.
  3. 3 Wrap the result in double quotes when you paste it into a JSON string, since the tool strips its own.
  4. 4 Run the companion JSON Unescape tool instead if your input is already escaped and you want it back.

Frequently asked questions

Why are the surrounding quotes missing from the output?

They are stripped on purpose. The tool returns the escaped payload of the string, so it can be dropped into the exact quoting context you need - a JSON value, a JavaScript string, a config line - rather than arriving pre-quoted for one of them.

What happens to accented or non-Latin characters?

They pass through unchanged. The escaping follows what a modern JSON serializer does, which is to leave non-ASCII characters as they are, so a name with an accent survives in readable form instead of becoming a wall of backslash-u escapes.

Can it escape a whole JSON document?

Not usefully. Pasting an object in escapes the quotes inside it, which flattens the structure into one long string - the braces and colons are untouched because they need no escaping, but the result is no longer valid JSON. It escapes string values, not documents.

What if my text is already escaped?

Run it the other way first. Escaping escaped input doubles every existing backslash, and this page has no detection for input that is already in escaped form. The JSON Unescape tool reverses the process in one step.

Free, online, and private

Free to use

JSON Escape is completely free. There is no account to create, no login, and no hidden charge or usage limit.

Runs online in your browser

It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.

Your data stays private

All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.

How JSON Escape behaves in detail

These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.

Parameter Value
Input one text panel, recalculated live on every keystroke; the sample reads He said "hi" followed by a newline and the words new line
Escape rule the text is passed through JSON.stringify and the surrounding quotes are stripped off the result
What gets escaped a double quote becomes backslash-quote, a backslash is doubled, newline becomes backslash-n, tab backslash-t and carriage return backslash-r
Control characters characters below the printable range are written as backslash-u escapes with four hexadecimal digits
Non-ASCII text accented letters and characters from other scripts pass through unchanged rather than being escaped
Output a single line of escaped text, without the surrounding quotes a JSON string literal would carry

Compiled from the implementation of this tool and checked against it by itoolnet.

What JSON Escape does not do

Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.

  • It escapes for a string value, not for a whole document. Pasting a complete JSON object in produces one flat escaped string whose braces and colons survive untouched - the structure is destroyed by design, and the page offers no way to escape only the string values inside a larger document.
  • The surrounding quotes are deliberately removed, so the output is the payload of a JSON string rather than a complete one. Pasting it directly into a .json file without adding the quotes back produces a syntax error that this page will not warn about.
  • Nothing flows the other way here. The page escapes only; unescaping a value that is already escaped is the job of the companion JSON Unescape tool, and running this page on escaped input doubles every backslash it finds.

Tested and documented by itoolnet, the team that builds and maintains this site.

Share & embed this tool

Writing a guide or article? You are welcome to link to JSON Escape with the snippet below. It is free, runs entirely in your browser, and needs no signup.