🐍 JSON 转 Python 字典/列表JSON to Python Dict Converter
把 JSON 转换为可直接粘贴进 Python 代码的字典/列表字面量:true/false/null 转成 True/False/None,可选单引号和缩进宽度。数据在本地处理。Convert JSON into a Python dict/list literal you can paste straight into code — true/false/null become True/False/None, with optional single quotes and indent width. Processed locally.
使用说明与常见问题How-to & FAQ
「JSON 转 Python 字典/列表」是什么?What is the JSON to Python Dict Converter tool?
把 JSON 转换为可直接粘贴进 Python 代码的字典/列表字面量:true/false/null 转成 True/False/None,可选单引号和缩进宽度。数据在本地处理。Convert JSON into a Python dict/list literal you can paste straight into code — true/false/null become True/False/None, with optional single quotes and indent width. Processed locally.
如何使用「JSON 转 Python 字典/列表」?How do I use the JSON to Python Dict Converter tool?
在「JSON 转 Python 字典/列表」中,把内容粘贴或输入到上方输入框,按需设置「缩进空格数」,结果会实时显示在下方,点击「复制结果」即可复制。In the JSON to Python Dict Converter: Paste or type into the input box, adjust "Indent spaces"; the result appears below instantly — click "Copy result" to copy it.
true、null 变成什么?What do true and null become?
JSON 的 true、false、null 分别转换为 Python 的 True、False、None;数字和字符串保持不变,嵌套的对象和数组转换为 Python 的 dict 和 list。JSON true, false and null become Python True, False and None; numbers and strings are kept as they are, and nested objects and arrays become Python dicts and lists.
单引号安全吗?Are single quotes safe?
勾选“使用单引号”时,字符串和键里的单引号和反斜杠会正确转义(\' 和 \\),所以结果仍是合法的 Python;取消勾选则输出双引号(与 JSON 相同)。With single quotes ticked, any single quote or backslash inside strings and keys is properly escaped (\' and \\) so the result stays valid Python; untick it to output double quotes (as in JSON).
能直接 import 吗?Can I paste it into code directly?
可以。输出是一个 Python 字面量表达式,赋值给变量即可,例如 data = {...};它不包含 import、函数或注释。超大整数等 JSON 本身不支持的内容不会出现。Yes. The output is a Python literal expression you can assign to a variable, for example data = {...}; it contains no imports, functions or comments. Anything JSON itself cannot represent will not appear.
缩进设为 0 会怎样?What does an indent of 0 do?
缩进为 0 时输出单行紧凑形式(如 {'a': 1, 'b': 2}),适合内联;大于 0 时每层缩进相应空格数,便于阅读。An indent of 0 gives a compact single-line form (such as {'a': 1, 'b': 2}) for inlining; a value above 0 indents each level by that many spaces for readability.
代码或数据会被上传吗?Is my code or data uploaded?
不会。「JSON 转 Python 字典/列表」完全用 JavaScript 在本地运行,适合处理含有密钥、内部接口等敏感内容的数据。No. The JSON to Python Dict Converter runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.
「JSON 转 Python 字典/列表」免费吗?需要注册吗?Is the JSON to Python Dict Converter free? Do I need an account?
「JSON 转 Python 字典/列表」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The JSON to Python Dict Converter is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.