Skip to main content
ToolsHub

JSON Escape / Unescape

Paste text to escape it into a valid JSON string literal, or paste an escaped string to decode it — instantly, in your browser.

Updated

Files never leave your browser

How to use JSON Escape / Unescape

The JSON Escape / Unescape tool converts text into a safe JSON string literal — or decodes an escaped string back to plain text — instantly in your browser. Escaping turns quotes, backslashes, newlines, tabs and other control characters into their backslash sequences so the result can be embedded inside a JSON document without breaking it. Unescaping reverses the process, turning \n, \t and \uXXXX sequences back into real characters. Everything runs locally with JavaScript, so even sensitive payloads never leave your device.

  1. Select the "Escape" tab to convert plain text into a JSON string, or "Unescape" to reverse it.
  2. Paste your text into the input area.
  3. For escaping, optionally enable "wrap in quotes" to produce a complete literal.
  4. Read the converted result in the output panel as you type.
  5. Click copy to grab the escaped or unescaped result for use in your code.

Your data never leaves your device — 100% private processing.

Which characters must be escaped in JSON?

The JSON specification (RFC 8259) requires that double quotes and backslashes always be escaped inside a string, along with the so-called control characters in the range U+0000 to U+001F. Common ones have short forms — \n for newline, \r for carriage return, \t for tab, \b for backspace and \f for form feed — while any remaining control character must use the six-character \uXXXX form. Forward slashes may optionally be escaped as \/ but this is never required. Getting these rules right by hand is error-prone, which is exactly why a dedicated escaper is useful when you are authoring JSON manually.

JSON escape sequences
CharacterEscapeNotes
Double quote\"Always required inside a string
Backslash\\Always required
Newline\nControl character shorthand
Tab\tControl character shorthand
Other control chars\uXXXXSix-character Unicode form

Escaping versus encoding

JSON escaping is not the same as URL encoding or HTML entity encoding, even though all three make text safe for a particular context. JSON escaping only deals with the handful of characters that would otherwise terminate or corrupt a JSON string — primarily quotes, backslashes and control characters. It does not touch letters, digits, spaces or most punctuation, which remain perfectly valid inside a JSON string. If you need to put a value into a URL you want URL encoding, and if you are inserting into HTML you want entity encoding. Reach for JSON escaping specifically when you are assembling a JSON document by hand or generating one in a templating context that lacks a proper serializer.

Worked examples

Escape a multi-line string

Inputs: line one line "two"

Result: line one\nline \"two\"

Unescape a JSON string

Inputs: tab\there

Result: tab here

Glossary

String literal
A run of characters surrounded by double quotes that represents a text value inside a JSON document.
Escape sequence
A backslash followed by one or more characters that represents a character which cannot appear literally, such as \n for a newline.
Control character
A non-printing character in the U+0000–U+001F range that must be escaped in JSON.
Unescape
The reverse operation that converts escape sequences back into the characters they represent.
RFC 8259
The IETF standard that defines the JSON data interchange format, including string-escaping rules.

Related reading

Frequently Asked Questions

Free · No spam

Get weekly tool tips & updates

New tools, power-user tips, and productivity hacks — delivered free every Friday.

No spam, ever. Unsubscribe with one click.

Why use JSON Escape / Unescape?

  • Turn arbitrary text into a valid JSON string literal you can paste straight into a JSON file
  • Optionally wrap the output in double quotes to get a complete, ready-to-use literal
  • Unescape JSON strings to recover the original multi-line text for reading and editing
  • Correctly handles control characters such as newline, tab, carriage return and form feed
  • Processes everything in your browser — no payload is ever uploaded

Common use cases

  • Embed a multi-line code snippet or log message inside a JSON config file
  • Build a JSON request body by hand in a REST client or documentation example
  • Decode an escaped JSON string copied from an API response to read it comfortably
  • Prepare text containing quotes and backslashes for a JSON-based test fixture
  • Inspect \uXXXX escape sequences by converting them back to readable characters

Related Developer Tools

Explore all Developer Tools.