JSON Formatter
Ready
Input
Output
Formatted JSON will appear here

What is this JSON Formatter?

This is a free, real-time JSON formatter and validator that runs 100% in your browser. No data is sent to any server. It supports formatting (beautifying), minifying, sorting keys alphabetically, and real-time validation with line-accurate error messages.

How does JSON formatting work?

JSON.parse() converts your text into an in-memory JavaScript object, then JSON.stringify() renders it back with proper indentation. This also validates the JSON as a side effect " any syntax errors are caught and displayed with the exact character position.

Is my data safe?

All processing is done entirely in your browser's memory using JavaScript. No data is sent to any server. When you close this tab, the data is gone. This makes it safe to use with API keys, tokens, or private configuration files.

What does "Sort Keys" do?

It recursively sorts all object keys alphabetically throughout the entire JSON structure. Useful for comparing two JSON objects for differences or enforcing consistent key ordering in config files.

What is JSON minifying?

Minifying removes all whitespace, newlines, and indentation from valid JSON. The result is functionally identical but smaller " useful for reducing payload size in HTTP API responses or configuration files.

Copied! "

How to Use This Tool

Escape JSON strings for safe embedding in code, or unescape escaped JSON back to readable format.

  1. Paste your JSON or string that needs escaping/unescaping into the input pane.
  2. To escape: the tool converts special characters (quotes, backslashes, newlines) into their escaped equivalents (\", \\, \n).
  3. To unescape: the tool converts escaped sequences back to their original characters, making the JSON readable again.
  4. Copy the result and use it in your code — escaped JSON is safe for embedding inside string literals in JavaScript, Python, Java, and other languages.

What Is JSON Escape / Unescape Tool?

JSON escaping converts special characters into safe escape sequences. For example, a double quote " becomes \", a backslash \ becomes \\, and a newline becomes \n. This is essential when embedding JSON inside string literals in code.

The reverse operation — unescaping — converts these escape sequences back to their original characters. This is useful when you receive a doubly-escaped JSON string from an API or log file and need to read the actual data.

Common scenarios include embedding JSON in HTML data attributes, passing JSON as a string parameter in URLs, and storing JSON inside other JSON strings (nested serialization).

Why You Need This

When you need JSON escaping:

Pro Tips for Best Results

Frequently Asked Questions

What characters need escaping in JSON?

Per RFC 8259: double quotes ("), backslashes (\), and control characters (\n for newline, \t for tab, \r for carriage return). Forward slashes (/) can optionally be escaped as \/ but it is not required.

What is double-escaped JSON?

When JSON is serialized as a string inside another JSON object, the inner quotes get escaped. If this happens twice (e.g., logging a JSON string), you get sequences like \\\" that need two rounds of unescaping to recover the original data.

How do I embed JSON in a JavaScript string?

Use JSON escaping to convert the JSON to a safe string, then wrap it in quotes: const data = JSON.parse("{\"name\":\"Alice\"}"). Or better, use a template literal with backticks and JSON.parse() directly.