Skip to content

JSON Escape/Unescape

Escape or unescape JSON strings online for safe embedding. Free JSON escape tool for handling quotes, backslashes, and special chars.

Data / JSONJSON Tools
Instant results

Escape Sequences Reference

\" → Double quote
\\ → Backslash
\n → Newline
\t → Tab
\r → Carriage return
\b → Backspace
\f → Form feed
\uXXXX → Unicode

About JSON Escape/Unescape

Escape text for use inside JSON strings, or unescape JSON strings back to plain text. Handles quotes, backslashes, newlines, tabs, and Unicode characters.

How to Use JSON Escape/Unescape

1

Paste your string

Drop in the text you want to process. Quotes, backslashes, newlines, and tabs are all fair game — the tool handles any input.

2

Choose direction

Pick whether to escape (encode for JSON) or unescape (decode an already-escaped string). Most tools support both directions.

3

View output

The tool displays the escaped or unescaped result, with special characters represented as the appropriate backslash sequences. The output is ready to drop into JSON contexts.

4

Copy and use

Copy the result and paste it into JSON payloads, generated code, database fields, or API requests where strings need to be escaped.

When to Use JSON Escape/Unescape

Embedding JSON in JSON

When your JSON document contains another JSON document as a string value (logs, embedded configuration, API metadata), each inner quote and backslash has to be escaped so the outer wrapper still parses cleanly. Log aggregation pipelines, multi-tenant configuration documents, and API payloads that carry nested JSON in a field all hit this constantly.

Code generation

When you generate JavaScript or another language from JSON data, strings need their special characters escaped before they can become valid string literals. This shows up in code generators, build tools, and ORM-less data layers that emit literal source code.

Database storage

Storing JSON inside a TEXT or VARCHAR column means special characters have to be escaped first so the value survives insertion intact. The tool produces a single escaped string ready for legacy databases and hybrid storage strategies that mix relational and document data.

API payload construction

When you build JSON payloads programmatically from user input, escaping is what prevents injection attacks, parser errors, and malformed payloads in general. API clients, form processors, and dynamic JSON builders all benefit from explicit escaping at the boundary.

JSON Escape/Unescape Examples

String with quotes

Input
He said "hello"
Output
He said \"hello\"

Double quotes get prefixed with a backslash. This is standard JSON escaping, and the tool also handles every other special character — backslashes, control characters, and Unicode escapes.

Multi-line text

Input
Line 1\nLine 2\nLine 3
Output
Line 1\\nLine 2\\nLine 3

Real newlines inside strings turn into the literal \\n escape sequence because JSON strings cannot contain raw newlines. The tool rewrites every embedded newline into its escape form automatically.

Already-JSON string

Input
{"key": "value"}
Output
{\"key\": \"value\"}

Here is JSON inside JSON. The inner quotes are escaped so the outer wrapper parses correctly, which is exactly the situation log entries containing JSON or nested configuration objects produce.

Tips & Best Practices for JSON Escape/Unescape

  • 1.Reach for the built-in JSON.stringify whenever you can — JavaScript already handles escaping correctly. The tool is most helpful when you want to see what is being escaped, learn the rules, or handle a one-off pasted string.
  • 2.Keep the escape sequences in mind. \n is newline, \t is tab, \\ is a literal backslash, \" is a quote, and \u00XX is Unicode. The tool handles all of them.
  • 3.Avoid double-escaping. If you escape an already-escaped string you end up with mangled output. Some tools detect that case automatically, but it pays to verify the input format before running it through.
  • 4.For production code, prefer the language's library — Python's json.dumps, JavaScript's JSON.stringify, and so on. The tool is best for pasted strings, debugging output, and learning.
  • 5.Watch for control characters below ASCII 0x20. Some tools strip them, others preserve them as \u00XX, and the right behavior depends entirely on your use case.
  • 6.Verify the round trip — escape, then unescape, then compare against the original. That quickly catches errors in either direction of the logic.

Frequently Asked Questions

Escaping is the process of converting special characters in a string to escape sequences so the string is valid inside JSON. The required escapes include backslash (\\), double quote (\"), the control characters (\n, \t, \r, and others), and Unicode (\uXXXX). Without proper escaping, the JSON parser rejects the string outright.