🔍

首页Home › 开发工具Developer Tools

🧩 JSON5 转 JSON(JSON5 校验与格式化)JSON5 to JSON Converter & Validator

把 JSON5 转换成标准 JSON,或把 JSON 写成更易读的 JSON5:支持注释、末尾逗号、单引号字符串、不加引号的键名、十六进制数、Infinity/NaN、多行字符串,出错时指出行号、列号并标出位置;键的顺序和大整数的每一位都原样保留。全部在浏览器本地完成。Convert JSON5 to standard JSON, or write JSON as more readable JSON5. Comments, trailing commas, single-quoted strings, unquoted keys, hex numbers, Infinity/NaN and multi-line strings are supported; errors show the line and column with a pointer. Key order and every digit of large integers are kept exactly. Everything runs locally in your browser.

使用说明与常见问题How-to & FAQ

「JSON5 转 JSON(JSON5 校验与格式化)」是什么?What is the JSON5 to JSON Converter & Validator tool?

把 JSON5 转换成标准 JSON,或把 JSON 写成更易读的 JSON5:支持注释、末尾逗号、单引号字符串、不加引号的键名、十六进制数、Infinity/NaN、多行字符串,出错时指出行号、列号并标出位置;键的顺序和大整数的每一位都原样保留。全部在浏览器本地完成。Convert JSON5 to standard JSON, or write JSON as more readable JSON5. Comments, trailing commas, single-quoted strings, unquoted keys, hex numbers, Infinity/NaN and multi-line strings are supported; errors show the line and column with a pointer. Key order and every digit of large integers are kept exactly. Everything runs locally in your browser.

如何使用「JSON5 转 JSON(JSON5 校验与格式化)」?How do I use the JSON5 to JSON Converter & Validator tool?

在「JSON5 转 JSON(JSON5 校验与格式化)」中,把内容粘贴或输入到上方输入框,按需设置「转换为」、「格式」、「JSON5 字符串引号」,结果会实时显示在下方,点击「复制结果」即可复制。In the JSON5 to JSON Converter & Validator: Paste or type into the input box, adjust "Convert to", "Format", "JSON5 string quotes"; the result appears below instantly — click "Copy result" to copy it.

JSON5 和 JSON 有什么区别?How is JSON5 different from JSON?

JSON5 是 JSON 的扩展,常用于配置文件:可以写 // 和 /* */ 注释,对象和数组末尾可以多一个逗号,字符串可以用单引号,键名是合法标识符时可以不加引号,数字可以写成十六进制(0x1F)、以小数点开头或结尾(.5、5.)、带正号,并支持 Infinity 和 NaN;字符串行尾加反斜杠可以换行续写。所有合法的 JSON 也都是合法的 JSON5。JSON5 extends JSON and is popular for config files: // and /* */ comments, trailing commas in objects and arrays, single-quoted strings, unquoted keys when they are valid identifiers, hex numbers (0x1F), leading or trailing decimal points (.5, 5.), a plus sign, Infinity and NaN, and strings continued across lines with a trailing backslash. Every valid JSON document is also valid JSON5.

Infinity 和 NaN 转成 JSON 会怎样?What happens to Infinity and NaN in JSON?

标准 JSON 没有 Infinity 和 NaN,这和 JavaScript 的 JSON.stringify 一样会写成 null,并在结果下方提示一共替换了几个。输出 JSON5 时会原样保留。Standard JSON has no Infinity or NaN, so, like JavaScript's JSON.stringify, they are written as null and a note below the result says how many were replaced. JSON5 output keeps them as they are.

大数字和键的顺序会变吗?Are large numbers and key order preserved?

不会变。工具自己解析文本,不经过 JavaScript 的数字类型,所以 12345678901234567890 这样的大整数和 0.1000 这样的小数每一位都原样保留(十六进制会换算成十进制);键的顺序也和原文一致,包括 "2"、"1" 这样的数字键。同一个对象里出现重复的键时保留最后一个值并给出提示。Yes. The text is parsed directly rather than through JavaScript numbers, so a large integer such as 12345678901234567890 or a decimal like 0.1000 keeps every digit (hex is converted to decimal), and keys stay in their original order, including numeric keys such as "2" and "1". If a key repeats in one object, the last value is kept and a note says so.

大段 JSON5 会卡住吗?Will a large JSON5 freeze the page?

粘贴没问题:大约 240 KB 的内容粘贴后通常一秒内就能转换完。卡住多半是因为在输入框里用键盘一个个字符敲进去(或自动化工具用模拟打字往框里填),浏览器每敲一个字都要重排超长文本,会越来越慢。请用 Ctrl+V / ⌘V 粘贴,或点选文件导入。Paste is fine: about 240 KB usually converts within a second after you paste. Freezes usually come from typing into the box character by character (or automation that simulates typing), because the browser reflows a huge textarea on every keystroke. Use Ctrl+V / ⌘V to paste, or load from a file.

出错时怎么定位?How do I find an error?

结果里会显示第几行、第几列和出错原因,例如缺少逗号、字符串里直接换行、数字以 0 开头、注释没有结束、多了一个逗号等,并在代码片段里用 ^ 标出位置。改正后结果会立即刷新。The result shows the line, column and reason, such as a missing comma, a raw line break in a string, a number with a leading zero, an unclosed comment or an extra comma, with a ^ marking the spot in a code snippet. Fix it and the result refreshes immediately.

数据会上传吗?Is my data uploaded?

不会,全部在浏览器本地处理。No — everything is processed locally in your browser.

「JSON5 转 JSON(JSON5 校验与格式化)」免费吗?需要注册吗?Is the JSON5 to JSON Converter & Validator free? Do I need an account?

「JSON5 转 JSON(JSON5 校验与格式化)」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The JSON5 to JSON Converter & Validator is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.

相关工具Related tools

🎨 CSS 颜色转换(OKLCH、Lab、Display P3)CSS Color Converter (OKLCH, Lab, Display P3)🔀 二进制 OR 运算(按位或)OR Binary Values⊽ 二进制 NOR 运算(或非)NOR Binary Values⊼ 二进制 NAND 运算(与非)NAND Binary Values🔃 二进制 NOT 运算(按位取反)NOT Binary Values🔄 二进制循环移位(位旋转 ROL / ROR)Rotate Binary Bits⬅️ 二进制左移(逻辑左移 <<)Shift Binary Left➡️ 二进制右移(逻辑右移 >>> / 算术右移 >>)Shift Binary Right🔀 二进制位随机打乱(洗牌,保持 1 的个数)Shuffle Binary Bits⊕ 二进制 XOR 运算(按位异或)XOR Binary Values⊙ 二进制 XNOR 运算(同或)XNOR Binary Values❝ CSV 加引号(按需或强制)Add CSV Quotes

← 全部工具All tools