JSON Escape & Unescape
Escape and unescape JSON strings with standard escape sequences. Converts special characters like quotes, backslashes, newlines, and tabs for safe embedding in code, HTML, or URLs. Includes validation and statistics.
Processing Mode
Recommended Settings
Common Escape Sequences
- •\" - Quotation mark (required in JSON strings)
- •\\ - Backslash (must be escaped to avoid ambiguity)
- •\n - Newline (line feed character)
- •\t - Tab (horizontal tab character)
Best Practices
- •Escape JSON before embedding in JavaScript string literals
- •Unescape JSON from logs or API responses for readability
- •Use escape mode when preparing data for code generation
- •Validate your JSON syntax before escaping for best results
Pro Tips
- •Escaping is reversible - unescape to restore original text
- •Forward slashes (/) can be escaped but it's optional
- •Unicode characters are represented as \uXXXX in JSON
- •Statistics show exact number of escape sequences added/removed
Most Popular
Most users escape JSON for embedding in code or documentation
When to Use This Tool
Escape JSON data before embedding it in JavaScript strings, HTML attributes, or configuration files. Perfect for generating code that includes JSON payloads, creating data attributes in HTML elements, or preparing JSON for string concatenation in any programming language where special characters need escaping.
Recommended: Code Generation
Prepare JSON examples for documentation, tutorials, blog posts, or Stack Overflow answers where JSON needs to be shown as escaped text. Essential when writing technical documentation that demonstrates how to handle JSON strings in code, showing proper escaping in curl commands, or teaching JSON handling best practices.
Recommended: Technical Writing
Escape JSON for safe transmission in URLs, headers, or database fields that don't support raw JSON. Critical for encoding JSON in query parameters, storing JSON in text fields without breaking SQL queries, or passing JSON through systems that don't handle special characters properly like legacy APIs or message queues.
Recommended: Data Engineering
How It Works
Paste or type text into the input area
Select 'Escape' mode to add escape sequences or 'Unescape' to remove them
Click the Escape or Unescape button to process
Tool converts special characters to/from their escape sequence form
Escape mode: quotes become \", newlines become \n, etc.
Unescape mode: \" becomes quotes, \n becomes newlines, etc.
Statistics show character counts, size changes, and escape sequences
Copy result to clipboard or download as text file
100% Private
Files never leave your device. All processing happens locally in your browser.
Lightning Fast
Powered by Client-side JavaScript using built-in JSON.stringify and JSON.parse methods for optimal performance on modern browsers.
Open Source
Built with verified, open-source libraries. Fully transparent.
Frequently Asked Questions
What characters get escaped in JSON?
The JSON specification requires escaping these characters: quotation marks ("), backslashes (\), and control characters like newlines (\n), carriage returns (\r), tabs (\t), backspace (\b), and form feed (\f). Additionally, any Unicode character can be represented as \uXXXX where XXXX is the 4-digit hexadecimal code point. Forward slashes (/) can optionally be escaped as \/ but it's not required.
What's the difference between escape and unescape?
Escape converts special characters into their escape sequence representations (e.g., newline becomes \n, quote becomes \"). Unescape does the reverse - it converts escape sequences back into their actual character representations (e.g., \n becomes a real newline). Escaping prepares text for safe transmission or storage, while unescaping restores the original characters for display or processing.
When should I escape vs unescape JSON?
Escape JSON when you need to: embed it in a string literal in code, include it in HTML attributes, pass it in URL parameters, or store it in systems that don't handle special characters. Unescape JSON when you need to: read escaped JSON from logs, process data received from APIs that escaped it, display escaped text in human-readable form, or convert escaped strings back to usable JSON objects.
Will escaping break my JSON?
No, escaping preserves the data - it just changes the representation. The escaped version can be safely unescaped back to the original. However, the escaped version is meant to be used as a string value, not as JSON structure. For example, if you escape a complete JSON object, you'll get a string representation that needs to be unescaped before it can be parsed as JSON again.
Can I escape already-escaped text?
Yes, you can escape text multiple times, and each level of escaping adds another layer of backslashes. For example, \n becomes \\n after a second escape. However, you need to unescape the same number of times to restore the original. Be cautious with multiple levels of escaping as it can quickly become confusing and hard to debug. Generally, you should only need one level of escaping.
Is my data safe and private?
Absolutely! All JSON escaping and unescaping happens entirely in your browser using client-side JavaScript. Your data is never sent to any server, uploaded anywhere, or stored. The tool uses JavaScript's built-in JSON.stringify() and JSON.parse() methods running 100% locally, ensuring complete privacy and security for your sensitive data, API keys, or confidential information.