Command Palette

Search for a command to run...

JS

JSON Escape / Unescape

Escape and unescape strings for JSON online - handles quotes, backslashes, newlines, tabs, control characters, and \uXXXX Unicode, with optional quote wrapping

What is JSON Escape / Unescape?

JSON Escape / Unescape is a tool that converts arbitrary text into a form that is safe to place inside a JSON string value, and reverses the process. Escaping replaces the characters that would break a JSON string - the double quote, the backslash, and control characters such as newlines and tabs - with their backslash escape sequences (\", \\, \n, \t, and \uXXXX). Unescaping turns those sequences back into the original raw characters.

This is different from formatting or validating JSON. A JSON formatter works on the structure of a whole document; this tool works on the contents of a single string. You reach for it when you need to embed a block of text - an HTML snippet, a SQL query, a multi-line log message, a code sample - inside a JSON field, or when you have a JSON-escaped string and want to read the original text behind all the backslashes.

Everything runs 100% in your browser with a hand-written escaper, so the text you paste - which is often a payload, a config value, or a piece of source code - never leaves your device. Optional settings let you wrap the result in double quotes to produce a complete JSON string literal, escape all non-ASCII characters as \uXXXX for maximum portability, or escape the forward slash for safe embedding inside a <script> tag.

Escaping is about producing a string that survives being embedded in JSON, which is a narrower job than it sounds. Control characters below U+0020 must be escaped and cannot appear literally, which is why a string containing a real newline is invalid until converted to a backslash n. Forward slashes may be escaped and do not have to be, a legacy of embedding JSON in HTML script tags where the sequence closing a script element would otherwise terminate it early. Unicode above the basic plane is stored as surrogate pairs, so a single emoji becomes two escape sequences and a string split in the middle of that pair is corrupt.

Here is a worked example of escape / unescape JSON on a multi-line SQL query. Paste the three lines SELECT *, FROM "users" and WHERE id = 1, tick Wrap in quotes and click Escape. The output is "SELECT *\nFROM \"users\"\nWHERE id = 1", one line with each newline turned into \n and each quote into \", ready to paste as a JSON value. Switch to Unescape, paste that result back, and the three original lines return with the outer quotes stripped. That round trip is the whole job of an escape unescape JSON tool.

How to use JSON Escape / Unescape?

  1. Paste your text

    Paste the raw text you want to embed in JSON, or the already-escaped JSON string you want to decode, into the input panel. Click Load Sample to see a multi-line example.

  2. Choose escape or unescape

    Pick Escape to convert raw text into a JSON-safe string, or Unescape to turn a JSON-escaped string back into its original characters.

  3. Set your options

    When escaping, optionally wrap the output in double quotes, escape all non-ASCII characters as \uXXXX, or escape the forward slash. Unescaping needs no options.

  4. Copy the result

    Copy the escaped or unescaped output to your clipboard and drop it straight into your JSON file, API request, or code.

Key Features

  • Escape and Unescape

    Convert raw text into a JSON-safe string and back again, both from the same tool with a single toggle

  • Full Control-Character Support

    Newlines, tabs, carriage returns, backspace, and form feed become \n, \t, \r, \b, and \f, while other control characters are escaped as \uXXXX

  • Optional Quote Wrapping

    Wrap the escaped output in double quotes to produce a complete, ready-to-paste JSON string literal

  • Unicode Escaping

    Optionally escape every non-ASCII character as \uXXXX so the output is pure ASCII and safe to transmit through any channel

Frequently Asked Questions

JSON string values cannot contain a raw double quote, a raw backslash, or raw control characters like newlines and tabs. Escaping replaces each of these with a backslash sequence - " becomes \", a newline becomes \n, a tab becomes \t - so the text can be placed inside a JSON string without breaking the surrounding structure.

Comments

0 comments

0/2000 characters

No comments yet. Be the first to share your thoughts!

json escapejson unescapeescape json stringjson string escapejson escape onlineunescape jsonjson stringify onlineescape quotes jsonjson special charactersescape / unescape jsonescape unescape jsonescape multiline string json