JSON 转义
转义与反转义 JSON 字符串中的特殊字符
Input
Output
Escape and unescape JSON string values
Embedding a JSON string inside another JSON string, an HTML attribute, or a shell command means you have to escape quotes, backslashes, and control characters. Doing it by hand is error-prone; a tool that escapes and unescapes correctly saves you from broken payloads and weird invisible characters that fail validation later.
Use the tool when you need to
Embed JSON inside a JSON string
Escape a payload so it can be stored as a string field inside another JSON document.
Build a curl command that posts JSON
Escape the body so the shell command stays valid when the payload contains quotes or backslashes.
Reverse an escaped value from a log line
Unescape a doubly-escaped string from a log so you can read what the original payload looked like.
How to escape JSON quickly
- 1
Paste the JSON string into the input area.
- 2
Click Escape to add the necessary backslashes, or Unescape to reverse them.
- 3
Copy the result and use it where you need an embedded or readable form.
Keep going
Encode binary as Base64
Pick Base64 when the value is binary rather than text.
Percent-encode URLs
Use URL encoding when the destination is a query string.
Format the JSON
Beautify the unescaped output to confirm the structure is intact.
Validate the result
Run a syntax check after escaping to confirm the value can round-trip.
Common escape/unescape workflows
Escape a JSON sample so it lives inside a string field in another JSON document.
Escape the request body so the resulting shell command is paste-safe.
Unescape a value from a log line to reconstruct what the original request looked like.
相关工具
常见问题
Escape JSON when you need to embed a JSON string inside another string — for example, storing a payload as a value in another JSON document, embedding JSON in a shell command, or putting JSON into an HTML attribute.
The tool escapes double quotes, backslashes, and control characters (newlines, tabs, etc.) according to the JSON specification. The escaped output is safe to embed inside another JSON string.
Escape adds backslashes so the value can be embedded as a string. Unescape reverses that, recovering the original JSON. If you have a doubly-escaped value (escaped twice), run unescape twice.
The tool follows JSON escaping rules. For URLs use the URL Encoder, for binary data use Base64, and for shell commands use shell-specific quoting — JSON escape is the right choice when the destination is JSON.
No. Escaping only adds backslashes so special characters are preserved as literal characters when the result is parsed as a JSON string. Round-tripping through escape and unescape returns the original value byte-for-byte.