JSON to Python Dict
Convert a JSON sample into an equivalent Python dict literal — valid identifier keys stay bare, invalid keys get quoted, and true/false/null become True/False/None.
Paste your JSON
How it works
- Parses the JSON with
JSON.parse - Renders keys as bare identifiers when they are valid Python identifiers, double-quoted strings otherwise
- Maps
true/false/nulltoTrue/False/Noneand single-quotes strings with escaping - Indents nested dicts and lists with 4 spaces
About JSON to Python
JSON and Python dict literals look similar but differ in the details: true/false/null become True/False/None, and while JSON requires every key to be double-quoted, Python lets valid identifiers be written bare and quotes anything else — like keys with hyphens or leading digits.
Reach for this tool when you are writing a Python script that needs test fixtures or a hard-coded dictionary copied from an API response. Watch out for deeply nested payloads (the indentation grows fast), and for numbers: the JSON passes through JavaScript numbers, so very large integers or floats can lose precision.