JSON Escape Tool

Escape special characters to create valid JSON strings. Paste your text below:

70 chars
Loading...
Loading...

Escape Reference

\"
Quote
\\
Backslash
\n
Newline
\t
Tab
\r
CR
\b
Backspace

What is JSON Escaping?

JSON strings have strict rules about special characters. Certain characters must be "escaped" with a backslash to be included in a JSON string. This tool automatically converts raw text into a properly escaped JSON string value.

Characters That Need Escaping

The JSON specification requires these characters to be escaped:

CharacterEscapedDescription
"\"Double quote — must be escaped inside strings
\\\Backslash — the escape character itself
Newline\nLine feed (LF)
Tab\tHorizontal tab
Carriage return\rCR (often paired with \n on Windows)
Backspace\bRarely used
Form feed\fPage break (legacy)

Example

Raw text:

Hello "World"
Line 2 with	tab

After escaping:

"Hello \"World\"\nLine 2 with\ttab"

When to Use This Tool

  • Building JSON manually — When concatenating strings into JSON
  • Embedding text in JSON — Multi-line content, quotes in values
  • API request bodies — Ensuring special characters don't break requests
  • Configuration values — File paths with backslashes
  • Debug JSON issues — Finding problematic characters

Escaping vs Stringify

This tool escapes a raw string. If you want to convert an entire JavaScript object to a JSON string, use JSON Stringify instead. The difference:

  • Escape: raw text → escaped string value
  • Stringify: JavaScript object → complete JSON

Options Explained

Wrap in quotes

Enable this to get a complete JSON string value with surrounding quotes. Disable it if you only need the escaped content to insert into an existing JSON structure.

Escape Unicode

When enabled, non-ASCII characters (é, 中, 🎉) are converted to \uXXXX format. This ensures compatibility with systems that don't support UTF-8, though modern JSON parsers handle Unicode natively.

Escaping in Code

In most cases, you should use your language's JSON library instead of manual escaping:

JavaScript

// Don't do this:
const json = '{"name": "' + name + '"}';

// Do this instead:
const json = JSON.stringify({ name: name });

// Or just the string:
const escaped = JSON.stringify(text);

Python

import json

# Escape a string
escaped = json.dumps(text)

# Build complete JSON
data = json.dumps({"name": text})

Why use libraries?

JSON libraries handle all edge cases correctly — Unicode, control characters, and encoding issues. Manual string building is error-prone and can create security vulnerabilities.

Common Mistakes

Forgetting to escape backslashes

Windows file paths like C:\Users\Name need double backslashes:C:\\Users\\Name

Not escaping quotes

A value containing " breaks the JSON structure unless escaped as \"

Raw newlines in strings

Multi-line strings must use \n — literal newlines are invalid in JSON strings

Related Tools

Frequently Asked Questions

What's the difference between escape and stringify?

Escape converts raw text into a valid JSON string value. Stringify converts an entire JavaScript object into a JSON string. Use escape for embedding text; use stringify for converting objects.

Do I need to escape forward slashes?

No. Forward slashes (/) are valid in JSON strings without escaping. Some tools escape them as \/ for HTML compatibility, but it's optional.

How do I escape Unicode characters?

Enable the "Escape Unicode" option to convert characters like é to\u00e9. This is only needed for legacy systems — modern JSON parsers handle UTF-8 natively.