About JSON to Python Dict
JSON to Python Dict writes a sample JSON object out as a Python dictionary literal with the keys quoted and the nesting preserved. It is the quickest way to turn an API response you have captured into a Python value you can paste into a script for a test fixture or a data transformation.
The structure survives the trip because JSON objects map onto dictionaries and JSON arrays onto lists — the two data models overlap almost completely for this kind of data. Nested objects stay nested, and the ordering of the keys is preserved as it appeared in the source.
One substitution is required before the generated code will run, and it is the usual trap in this conversion. The values are emitted in JSON form, so boolean values appear as lowercase true and false and a null appears as null. Python spells those True, False and None. The output is otherwise a valid literal, and it is deliberately wrapped in an assignment so it can be pasted straight into a module without further editing.
How to use JSON to Python Dict
- 1 Paste the JSON object you want as a Python literal.
- 2 Copy the generated assignment into your script.
- 3 Replace the JSON spellings of booleans and null with their Python equivalents.
Frequently asked questions
Why do true and null break when I paste the output?
Because the values are serialised in JSON notation, which shares its syntax with Python for strings, numbers, lists and dicts but not for booleans and the null value. Replace them with True, False and None and the literal runs as written.
Are non-ASCII characters escaped?
They are preserved as the characters themselves rather than being turned into escape sequences, which keeps the generated file readable. If your source file is not declared as UTF-8, add an encoding declaration before importing it.
Can I use this for a JSON array instead of an object?
Yes — an array comes out as a list literal bound to the same name. The assignment form is the same either way, so the surrounding code does not need to change.
Free, online, and private
Free to use
JSON to Python Dict is completely free. There is no account to create, no login, and no hidden charge or usage limit.
Runs online in your browser
It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.
Your data stays private
All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.
How JSON to Python Dict behaves in detail
These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.
| Parameter | Value |
|---|---|
| Output shape | one assignment, data = { ... }, with a double-quoted key for each top-level entry |
| Value rendering | values are written with JSON.stringify rather than a Python serialiser |
| Line endings | every entry ends in a comma, including the last one, which Python accepts |
| Indentation | two spaces per key, and each value occupies a single line no matter how deeply it nests |
| Root requirement | Object.entries is applied to the parsed value, so a root array turns into a mapping keyed by index strings |
Compiled from the implementation of this tool and checked against it by itoolnet.
What JSON to Python Dict does not do
Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.
- Values come out of JSON.stringify, not a Python repr, so null, true and false are written as the bare tokens null, true and false — the file raises NameError as soon as Python reads it unless you substitute None, True and False.
- Nesting is flattened to one line per key: a nested object or a long array arrives as a single dense JSON expression, so there is no indented structure and no line you can edit without counting brackets.
- Nothing is converted between the two worlds. Strings that look like dates or decimals stay strings, the variable is always named data, and no type annotations, dataclasses or imports are generated.
Tested and documented by itoolnet, the team that builds and maintains this site.