Json Escape
Replace " to \" in the Json
Input
Output
What It Does
The JSON Escape tool instantly converts raw text into a safely escaped string that can be embedded inside any JSON document without breaking the structure. JSON has strict formatting rules: certain characters like double quotes, backslashes, newlines, carriage returns, and tab characters carry special meaning within the syntax. If these characters appear unescaped inside a JSON string value, they will corrupt the entire document and cause parse errors in every language and framework that tries to read it. This tool handles every required escape sequence defined by the JSON specification — converting double quotes to \", backslashes to \\, newlines to \n, carriage returns to \r, tabs to \t, form feeds to \f, backspaces to \b, and any remaining non-printable control characters to their \uXXXX Unicode escape equivalents. Whether you are building REST API payloads by hand, writing JSON configuration files, embedding user-generated content into a data structure, or debugging a malformed JSON string, this tool gives you a clean, spec-compliant output in seconds. No setup, no library imports, no runtime environment required — paste your text and get an escaped result you can drop directly into any JSON string value with confidence.
How It Works
The Json Escape applies its selected transformation logic to your input and produces output based on the options you choose.
It applies a fixed set of transformation rules to your input, so the output is stable and easy to verify.
All processing happens in your browser, so your input stays on your device during the transformation.
Common Use Cases
- Escaping error messages or stack traces before embedding them as values in a JSON logging payload sent to a monitoring service
- Preparing multi-line SQL queries or code snippets for storage inside a JSON configuration file without breaking the document structure
- Sanitizing user-submitted form content — such as comments or bio text — before serializing it into a JSON API request body
- Manually constructing JSON strings in a terminal or script where a serialization library is not available
- Embedding file paths on Windows systems, which contain backslashes that must be doubled to be valid inside JSON strings
- Converting HTML or XML snippets that contain double quotes into JSON-safe values for use in a content management or templating system
- Debugging a JSON parse error by identifying and escaping the specific special character causing the malformed string
How to Use
- Paste or type the raw text you want to escape into the input field — this can be a single sentence, a multi-line paragraph, a code snippet, or any string containing special characters
- The tool processes your input in real time, scanning every character and replacing any that require escaping according to the official JSON specification (RFC 8259)
- Review the escaped output in the result field to confirm all backslashes, quotes, newlines, and control characters have been converted to their correct escape sequences
- Copy the escaped output using the copy button, then paste it directly between the enclosing double quotes of your target JSON string value
- Validate your final JSON document in a JSON linter or validator to confirm the escaped string integrates cleanly with the surrounding structure
Features
- Escapes all RFC 8259 required characters including double quotes, backslashes, and the full set of ASCII control characters from U+0000 to U+001F
- Converts literal newline characters (\n), carriage returns (\r), horizontal tabs (\t), form feeds (\f), and backspaces (\b) to their standard two-character JSON escape sequences
- Encodes remaining non-printable and control characters as \uXXXX Unicode escape sequences to ensure the output is always printable and pasteable
- Processes input in real time with no button click required, giving immediate feedback as you type or paste content
- Handles arbitrarily long strings including multi-paragraph text, code blocks, and structured data without truncation
- Produces output that is ready to embed between existing double quotes in a JSON value — no additional wrapping or formatting needed
- Runs entirely in the browser, meaning your text is never sent to a server, making it safe to use with sensitive configuration values or private data
Examples
Below is a representative input and output so you can see the transformation clearly.
{"path":"C:\\temp\\file.txt"}{\"path\":\"C:\\\\temp\\\\file.txt\"}Edge Cases
- Very large inputs may take a few seconds to process in the browser. If performance slows, split the input into smaller batches.
- Mixed formatting (tabs, line breaks, or inconsistent delimiters) can affect output. Normalize spacing first if needed.
- Json Escape follows the selected options strictly. If the output looks unexpected, re-check option settings and input format.
Troubleshooting
- Output looks unchanged: confirm the input contains the pattern this tool modifies and that the correct options are selected.
- Output differs from a previous run: confirm that the input and every option match, because deterministic tools should repeat when the settings are identical.
- Unexpected characters: check for hidden whitespace or encoding issues in the input and try normalizing first.
- Slow processing: reduce input size or try a modern browser with more available memory.
Tips
Always escape text before manually constructing JSON rather than after — it is far easier to escape a known value than to diagnose why a parser is failing on an already-assembled document. If you are working with Windows file paths, remember that every single backslash must become a double backslash in JSON, so a path like C:\Users\name becomes C:\\Users\\name. For very large payloads, consider whether your use case would benefit from a full JSON formatter or serializer instead, since those tools escape values automatically as part of the serialization process. When embedding code snippets or regex patterns that contain both backslashes and quotes, double-check the escaped output carefully — these are the most common sources of subtle escaping errors.
Frequently Asked Questions
What characters need to be escaped in a JSON string?
According to RFC 8259, the JSON standard, the characters that must be escaped inside a JSON string are the double quote ("), the backslash (\), and all Unicode control characters in the range U+0000 through U+001F. The standard provides shorthand escape sequences for the most common control characters: \b (backspace), \f (form feed), \n (newline), \r (carriage return), and \t (tab). Any other control characters in that range must be written as \uXXXX four-digit hex sequences. Characters outside this range, including most Unicode letters, digits, and symbols, do not need to be escaped and can appear literally in JSON strings.
Why does my JSON break when I include text with line breaks or quotes?
JSON strings must be written on a single logical line — a literal newline character inside a JSON string terminates the string unexpectedly, causing a parse error in every JSON parser. Similarly, an unescaped double quote inside a string value is interpreted as the closing delimiter of that string, which breaks the document structure for everything that follows. To safely include multi-line text or text containing quotes, you must escape newlines as \n and double quotes as \". A JSON escape tool handles both transformations automatically.
What is the difference between JSON escaping and URL encoding?
JSON escaping and URL encoding are two completely separate systems designed for different contexts. JSON escaping uses backslash-based sequences (like \n, \", \\) to make characters safe for use inside JSON string values. URL encoding, also called percent-encoding, uses a percent sign followed by a two-digit hex code (like %20 for space, %3A for colon) to make characters safe for use inside URLs. Applying URL encoding to a string does not make it JSON-safe, and vice versa. If you need to embed a URL inside a JSON string, you URL-encode the URL for its own purposes, then JSON-escape the result if it contains characters like backslashes or quotes.
Do I need to add surrounding double quotes when using the escaped output?
Yes — the output of a JSON escape tool is the content of a string value, not a complete JSON string literal. You still need to wrap the escaped output in double quotes when placing it inside a JSON document. For example, if the escaped output is Hello \"world\", you would write it as \"Hello \\\"world\\\"\" in your JSON file. The tool does not add the surrounding quotes for you because the intended use is to drop the escaped content into an existing string slot in a document you are already editing.
Is it safe to use an online JSON escape tool with sensitive data?
It depends on the tool. Many online tools process text entirely in the browser using JavaScript, meaning your input is never transmitted to any server — this is the safest option for sensitive configuration values, API keys, or private content. However, some tools do send input to a backend for processing. Before using any online tool with sensitive data, check whether processing happens client-side or server-side. As a general practice, avoid pasting real production secrets, passwords, or personally identifiable information into any third-party web tool when an offline alternative or a quick code snippet in your own environment would work just as well.
How does JSON escaping differ from what JSON.stringify() does automatically?
JSON.stringify() in JavaScript (and equivalent serialization functions in other languages) automatically escapes all necessary characters when converting a native value to a JSON string — you do not need to manually escape anything when using these functions. Manual JSON escaping is only necessary when you are constructing JSON by hand, writing raw string literals in source code, editing JSON files in a text editor, or working in an environment where a serialization library is not available. Think of a JSON escape tool as a manual stand-in for the escaping step that JSON.stringify() performs internally.