---
title: "JSON Escape Online: Turn JSON into a String | Prettify"
description: Escape JSON into one string literal in your browser. Quotes,
  backslashes, and line breaks are escaped, ready to embed in code or JSON. No
  upload.
url: https://prettify.tools/json-escape
---

# JSON Escape

Paste JSON and get it back as one escaped string literal, with every quote and backslash escaped. Use the result to put a JSON document inside another JSON value, a string in code, or a test fixture. Prettify minifies the document first, so the string stays on one line.

## What escaping does

A JSON string starts and ends with a double quote, so a double quote inside it must be written as \\". A backslash must be written as \\\\, and a line break as \n. Escaping a document applies those rules to the whole text, so the document becomes the value of one string.

Prettify parses your JSON before it escapes it. A document with a syntax error shows the line and column of the error instead of an escaped string that would fail later.

## Key features

The escaped string is ready to paste where a JSON string or a string literal is expected.

- Double quotes become \\" and backslashes become \\\\.
- A \n or \t inside a value is escaped again, so it reads back as the same two characters.
- Other control characters become \u escapes.
- Accented letters and emoji stay as they are, because a JSON string may hold them.
- The document is minified first, so the string has no line breaks of its own.
- Numbers keep their exact digits, and key order does not change.

## How to escape JSON

Escape in the box on this page, or copy the open document as a string in the editor. The box takes documents up to 512 KB.

1. Paste your JSON into the box labeled "Paste your JSON", or select "Try an example".
2. Read the escaped string in the result panel. It starts and ends with a double quote.
3. Select Copy to put the string on the clipboard, or Download to save it as prettify.json.
4. In the editor, open the command palette with Cmd+K (Ctrl+K on Windows and Linux) and run Copy as JSON String.

## Worked example: an event payload

The payload below has a nested object, a name with an accented letter, and a message with an escaped line break. The second block is the result from the box.

Every quote is now \\". The \n in the message became \\\n, so when a program reads the string and then parses it, the message still holds a line break. The letter ë did not change.

```
{
  "event": "signup",
  "user": { "id": 42, "name": "Zoë" },
  "message": "Line one\nLine two"
}

"{\"event\":\"signup\",\"user\":{\"id\":42,\"name\":\"Zoë\"},\"message\":\"Line one\\nLine two\"}"
```

## Where you need escaped JSON

Many systems store or send a JSON document as text inside another document. Escaping by hand is slow, and one missed quote breaks the whole value.

- An API field that takes a JSON document as a string, such as a message body or a stored payload.
- A test that embeds a JSON fixture in a string literal.
- A queue message or a log line that carries a JSON payload.
- A YAML or JSON config value that holds JSON for another tool.

## Limits to know

The tool expects a JSON document, so it can check the input first. To escape text that is not JSON, use the string escaping of your programming language instead.

Comments and trailing commas are accepted in the input, but they are not data, so they are not in the escaped string. To reverse the result, use JSON Unescape, which turns the string back into the document.

## Escaping in code

In code, escaping is one more call to the JSON serializer. In JavaScript, JSON.stringify(JSON.stringify(data)) gives the same kind of string as this tool. In Python, json.dumps(json.dumps(data)) does the same. The inner call writes the document, and the outer call writes that text as a string.

Use this page when you have the JSON as text and no code to hand: a payload from a log, a response from a browser tab, or a fixture in a ticket. The box also checks the JSON first, which a serializer in code does only when it parses the text.

## Frequently asked questions

### How do I unescape the string again?

Paste it into the JSON Unescape tool. The editor also opens escaped JSON directly: paste it, and it opens as the document it holds, with a note that says so.

### Is my JSON uploaded?

No. Prettify parses and escapes the JSON in your browser, so the document never leaves your device. You can escape payloads that hold tokens or personal data.

### Why is the result on one line?

The document is minified before it is escaped. A formatted document would fill the string with \n escapes, which makes the string longer and harder to read.

### Are non-ASCII characters escaped?

No. Letters such as ë and ñ and emoji stay as they are, because JSON strings may hold any Unicode character. Only quotes, backslashes, and control characters are escaped.

### Is JSON escaping free?

Yes. Escaping on this page and with Copy as JSON String in the editor is free, with no account and no limit on use.

## Related tools

- [JSON Unescape](https://prettify.tools/json-unescape)
- [Minify JSON](https://prettify.tools/minify-json)
- [JSON Formatter: Prettify and Pretty Print JSON](https://prettify.tools/json-formatter)
- [JSON Validator](https://prettify.tools/json-validator)
- [JSON Editor Online](https://prettify.tools/json-editor)
- [JWT Decoder](https://prettify.tools/jwt-decoder)

## Structured data

```json
{
  "@context": "https://schema.org",
  "@type": "SoftwareApplication",
  "name": "Prettify",
  "url": "https://prettify.tools",
  "description": "Multi-format data viewer, editor, and query engine for JSON, YAML, CSV, XML, Mermaid, Markdown, MDX, HTML, and SVG",
  "applicationCategory": "DeveloperApplication",
  "operatingSystem": "Web, macOS, Windows, Linux",
  "offers": [
    {
      "@type": "Offer",
      "price": "0",
      "priceCurrency": "USD",
      "description": "Free tier with core features"
    },
    {
      "@type": "Offer",
      "price": "19.99",
      "priceCurrency": "USD",
      "description": "Pro: lifetime access to all features"
    }
  ],
  "publisher": {
    "@id": "https://prettify.tools/#organization"
  }
}
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "@id": "https://prettify.tools/#organization",
  "name": "Prettify",
  "legalName": "Off Leash Labs",
  "url": "https://prettify.tools/",
  "logo": {
    "@type": "ImageObject",
    "url": "https://prettify.tools/icon-512.png",
    "width": 512,
    "height": 512
  },
  "contactPoint": {
    "@type": "ContactPoint",
    "contactType": "customer support",
    "email": "offleashlabs@gmail.com",
    "availableLanguage": "English"
  }
}
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "WebPage",
      "@id": "https://prettify.tools/json-escape",
      "url": "https://prettify.tools/json-escape",
      "name": "JSON Escape Online: Turn JSON into a String | Prettify",
      "description": "Escape JSON into one string literal in your browser. Quotes, backslashes, and line breaks are escaped, ready to embed in code or JSON. No upload.",
      "isPartOf": {
        "@type": "WebSite",
        "name": "Prettify",
        "url": "https://prettify.tools"
      }
    },
    {
      "@type": "FAQPage",
      "mainEntity": [
        {
          "@type": "Question",
          "name": "How do I unescape the string again?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "Paste it into the JSON Unescape tool. The editor also opens escaped JSON directly: paste it, and it opens as the document it holds, with a note that says so."
          }
        },
        {
          "@type": "Question",
          "name": "Is my JSON uploaded?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "No. Prettify parses and escapes the JSON in your browser, so the document never leaves your device. You can escape payloads that hold tokens or personal data."
          }
        },
        {
          "@type": "Question",
          "name": "Why is the result on one line?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "The document is minified before it is escaped. A formatted document would fill the string with \\n escapes, which makes the string longer and harder to read."
          }
        },
        {
          "@type": "Question",
          "name": "Are non-ASCII characters escaped?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "No. Letters such as ë and ñ and emoji stay as they are, because JSON strings may hold any Unicode character. Only quotes, backslashes, and control characters are escaped."
          }
        },
        {
          "@type": "Question",
          "name": "Is JSON escaping free?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "Yes. Escaping on this page and with Copy as JSON String in the editor is free, with no account and no limit on use."
          }
        }
      ]
    }
  ]
}
```
