TOOLGRIDTOOLGRID
首页图片工具PDF 工具视频工具音频工具
More
开发工具Web 与 SEO分类文本工具计算器测试方法关于
Menu
首页图片工具PDF 工具视频工具音频工具开发工具Web 与 SEO分类文本工具计算器测试方法关于
109 个工具已上线
TOOLGRIDTOOLGRID

需要某项具体功能时,完整工具箱始终可用。

© 2026 TOOLGRID. All rights reserved.

Tools

图片工具PDF 工具视频工具音频工具转换工具开发工具Web 与 SEO文本工具计算器

Resources

分类测试方法隐私政策

Company

关于条款联系
转换工具
  1. 首页
  2. Converters
  3. JSON Escape / Unescape
属于 Converters →

JSON Escape / Unescape

Escape a string for safe embedding in a JSON value, or unescape a JSON-encoded string back to plain text.

开始使用这个工具
浏览器本地处理不向 TOOLGRID 上传输入复制前先检查
DEVELOPER 工作流JSON Escape / Unescape 能力卡
输入
Pasted text or typed values
输出
JSON Escape / Unescape result
运行引擎
Browser APIs
审核日期
2026-07-17
浏览器本地工作区在下方开始,使用浏览器本地处理。

工具代码会在浏览器中处理所选文件和输入内容,不会将其提交给 TOOLGRID 的处理接口。 TOOLGRID 只衡量工具使用情况,不记录你输入的内容。

  • 不上传工具输入至 TOOLGRID
  • 不登录
  • 复制前先检查

Loading tool…

浏览器内运行

这个工具能做什么

01

In-browser JSON escape / unescape via JSON.stringify and JSON.parse. Optional outer-quote inclusion. Both directions supported.

02

Paste any text and the tool produces a JSON-safe escaped version: " becomes \", \ becomes \\, newlines become \n, tabs become \t, and any non-ASCII characters that the JSON spec considers escapable get escaped. The output is ready to drop directly inside a JSON string value.

03

Toggle "Include outer quotes" on if you want the full JSON string literal (with leading and trailing ") ready to paste into a JSON document as-is. Off (default) gives you the inside of the string, which is what you usually want when concatenating or templating.

04

Switch to Unescape mode to go the other direction: paste a JSON-escaped string (with or without the outer quotes) and the tool decodes the escape sequences back to the original characters — useful when reading webhook payloads, copy-pasting strings out of JSON logs, or inspecting JSON-encoded values from a database.

05

All processing uses JavaScript's built-in JSON.stringify / JSON.parse — the same rules as every JSON library and browser. Tool code processes selected files and entered content in your browser and does not submit them to a TOOLGRID processing endpoint. Pair with JSON Formatter when the surrounding document needs pretty-printing, or HTML Escape when the text will eventually be rendered as HTML.

代表性任务

这个工具适合解决什么问题

Embed a multi-line message in a Slack / Discord webhook

Webhooks expect a JSON body where the message text is a JSON string value. Multi-line messages or messages containing quotes break the JSON if pasted raw — escape them here first.

Build a GraphQL query with string arguments

When sending a GraphQL query as a JSON body, the query string itself is a JSON value. Backslashes, quotes, and newlines inside the query need to be JSON-escaped — drop the raw query in to get the safe form.

Inspect a JSON-encoded value from a log or database

Many systems store complex strings as JSON-encoded values (e.g., error stack traces with quotes). Paste the encoded form into Unescape mode to recover readable text.

使用边界

依赖结果前需要检查什么

  • Performance and maximum practical input size depend on browser memory, device speed, and the structure of the input.
  • Review the generated result before replacing or publishing an original file.
MDN Web APIs
继续当前流程下一步常用工具

如果还需要校验、转换或复用结果,可以继续打开相近的浏览器本地工具。

当前结果
产物转换输出动作复制结果
HTML Escape / Unescape转换工具本地产物转换输出动作复制结果立即本地使用→URL 编码解码转换工具本地产物转换输出动作复制结果立即本地使用→JSON 格式化工具数据格式本地产物格式化 JSON动作复制结果立即本地使用→

如何使用

01
01Pick Mode: Escape to encode plain text into JSON-safe form, or Unescape to decode it back.
02Toggle "Include outer quotes" in Escape mode if you want the full JSON string literal (with surrounding quotes).
03Paste your input. The escaped or unescaped output regenerates live as you type.

使用场景

Embed a multi-line message in a Slack / Discord webhook

Webhooks expect a JSON body where the message text is a JSON string value. Multi-line messages or messages containing quotes break the JSON if pasted raw — escape them here first.

Build a GraphQL query with string arguments

When sending a GraphQL query as a JSON body, the query string itself is a JSON value. Backslashes, quotes, and newlines inside the query need to be JSON-escaped — drop the raw query in to get the safe form.

Inspect a JSON-encoded value from a log or database

Many systems store complex strings as JSON-encoded values (e.g., error stack traces with quotes). Paste the encoded form into Unescape mode to recover readable text.

Generate an env var holding a JSON value

When an environment variable needs to hold a JSON document (Vercel, Docker, Kubernetes), the variable value is a string and the JSON inside it must be self-consistent. Escape the JSON document with outer quotes off, then wrap with single quotes in your env file.

Convert a multi-line code snippet to a single-line JSON-safe string

When sharing code samples in a JSON-based API (issue tracker, documentation system), the code becomes a JSON string. Escape converts your <code>\n</code>-separated code into a single-line escaped form that round-trips cleanly.

使用技巧

  1. 01
    JSON escape ≠ URL encode ≠ HTML escape

    JSON escape handles characters that would break a JSON string value (<code>"</code>, <code>\</code>, control chars, newlines). URL encoding handles URL-reserved characters (<code>?</code>, <code>&amp;</code>, spaces). HTML escape handles HTML-reserved characters (<code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>). Pick the encoding that matches the context the string will live in.

  2. 02
    Outer quotes matter for paste-and-go

    With outer quotes ON, the output is a complete JSON string literal you can paste directly into a JSON document. With OFF, you get the inside of the string — useful for template-string concatenation in code where you'll add quotes yourself.

  3. 03
    Unicode characters above U+FFFF use surrogate pairs

    JSON encoding of emoji and rarely-used scripts uses the <code>\uHHHH\uHHHH</code> surrogate-pair convention. Most JSON parsers handle this correctly; if a downstream system rejects surrogates, that's a parser bug — not a JSON spec issue.

  4. 04
    Round-tripping is loss-free

    Escape then immediately Unescape should return the exact original text. If it doesn't, the unescape input is malformed (typically a stray <code>\</code> at the end, or unclosed escape sequence). Watch for this when copy-pasting from formatted log output that may have wrapped lines mid-escape.

常见问题

02
What characters does JSON escape encode?

Per the JSON spec (RFC 8259): the quote character <code>"</code> becomes <code>\"</code>; backslash <code>\</code> becomes <code>\\</code>; control characters (U+0000 through U+001F) become <code>\u00XX</code> escapes; common ones have shortcuts: newline → <code>\n</code>, tab → <code>\t</code>, carriage return → <code>\r</code>, form feed → <code>\f</code>, backspace → <code>\b</code>. All other Unicode characters pass through unchanged (the spec allows raw UTF-8 in JSON strings).

What's the difference between Escape and Unescape modes?

Escape takes plain text and produces a JSON-safe version (e.g., <code>he said "hi"</code> → <code>he said \"hi\"</code>). Unescape goes the opposite direction. They're inverses: escape→unescape should give you back the original.

When should I include the outer quotes?

Include them (toggle ON) when you'll paste the result directly into a JSON document as a complete value. Exclude them (default OFF) when the output will be concatenated or templated into code that adds the quotes itself.

Is JSON escape the same as JavaScript string escape?

Very similar but not identical. JavaScript strings allow single quotes and a few escapes (like <code>\v</code> for vertical tab and <code>\x41</code> for ASCII) that JSON doesn't. Stick to JSON escape when the destination is JSON; use a JavaScript-specific encoder when the destination is JS source code.

What about HTML or URL contexts — can I use this output there?

No. JSON-escaped text is safe inside a JSON string; it's NOT safe in HTML (where <code>&lt;</code> and <code>&gt;</code> need entity encoding) or URLs (where reserved characters need percent-encoding). If the JSON value will eventually be rendered as HTML or used in a URL, apply additional layer-appropriate encoding on top.

Is my input sent to a server?

JSON escape/unescape uses the browser's built-in <code>JSON.stringify</code> and <code>JSON.parse</code>. Tool code processes selected files and entered content in your browser and does not submit them to a TOOLGRID processing endpoint. Browser-local processing avoids a TOOLGRID upload path, but it is not a blanket security guarantee.

Why does Unescape fail on my input?

Most common causes: (1) the input has unbalanced escape sequences (a stray <code>\</code> at the end), (2) the input has unescaped control characters that the JSON spec doesn't allow, (3) the input is just plain text without any actual escapes (try running it through Escape first to see what valid escaped form looks like).

相关工具

03
本地

HTML Escape / Unescape→立即本地使用No TOOLGRID input upload

Escape HTML entities for safe rendering or decode entities back to text. XSS-aware with attribute-safe mode.

转换输出复制结果

本地

URL 编码解码→立即本地使用No TOOLGRID input upload

把文本转换为 URL percent encoding,或把编码内容还原为可读文本。

转换输出复制结果

本地

JSON 格式化工具→立即本地使用No TOOLGRID input upload

格式化、压缩并校验 JSON,快速定位语法错误。

格式化 JSON复制结果