🛡️ 转义 / 反转义Escape / Unescape

在 HTML、XML、JavaScript、JSON、URL、CSV 六种格式间转义或还原文本,便于把任意字符串安全地写进代码或数据。Escape or unescape text across HTML, XML, JavaScript, JSON, URL and CSV — safely embed any string into code or data.

① 格式与方向① Format & Direction

② 输入与输出② Input & Output

📚 为什么需要转义?📚 Why escape at all?

不同环境对「特殊字符」的解读不同:HTML 里 `<` 开始一个标签,URL 里 `&`/`#` 有语义,JSON/JS 字符串里引号与反斜杠会截断字符串。转义就是把用户输入中的特殊字符改成环境安全的形式(如 `<` → `<`),从而防止两件事:数据被误解析(显示/传输错乱),以及**注入攻击**——最常见的 Web 漏洞之一(XSS:把未转义的用户内容放进 HTML,恶意脚本被执行;SQL 注入同理)。Different contexts interpret “special characters” differently: in HTML `<` starts a tag, in URLs `&`/`#` have meaning, in JSON/JS strings quotes and backslashes terminate the string. Escaping rewrites user input into a context-safe form (e.g. `<` → `<`), preventing two things: data being mis-parsed (broken display/transfer), and injection attacks — one of the most common Web vulnerabilities (XSS: unescaped user content placed into HTML lets malicious scripts run; SQL injection works the same way).

本工具覆盖常见转义方向:HTML/XML(`<&"` 等实体)、JavaScript(`\n`/`\'`/`\"`)、JSON(`JSON.stringify` 引号转义)、URL(`encodeURIComponent`)、CSV(双引号包裹与 `""` 转义)、Base64(二进制→文本)、Unicode `\uXXXX` 以及 SQL(单引号加倍)。反转义则把安全形式还原为原文——两者配合即可实现「存入时转义、取出时还原」的完整闭环。This tool covers the common directions: HTML/XML entities, JavaScript `\n`/`\'`/`\"`, JSON quoting, URL encoding, CSV quoting with `""`, Base64, Unicode `\uXXXX` and SQL single-quote doubling. Unescaping reverses these — together they form the complete “escape on store, unescape on load” loop.

使用说明How to use

怎么用How to use
  1. 输入要转义的内容Enter content to escape
  2. 选择格式:HTML/XML/JS/JSON/URL/CSVChoose format: HTML/XML/JS/JSON/URL/CSV
  3. 转义或反转义Escape or unescape

示例: → <b>Example: → <b>

全程在你的浏览器本地完成,文本不会上传服务器。Runs entirely in your browser; your text is never uploaded.