JSON to Python Dict

FreePrivateInstant
JSON input
Python output
Ctrl+Enter Convert to Python

JSON to Python Dict Generator

Paste a JSON object or array and get a Python dictionary or list with the correct Python literal syntax. JSON null becomes None, true/false become True/False, and numbers stay as integers or floats. Runs entirely in your browser.

Where Is This Useful?

Jupyter notebooks and data scripts
Need to paste a JSON API response as a Python dict into a Jupyter notebook without calling json.loads()? Convert it here and paste the literal directly into a cell for instant data exploration.
Test fixtures and unit tests
Writing unit tests that use a fixed data structure? Convert the expected JSON fixture to a Python dict literal that you can paste directly into your test file as a constant.
Django and Flask response mocking
When mocking an API response in a Django or Flask test, you often need a Python dict. Convert the real API response JSON here to get the exact Python structure for your mock.

How to Use

  1. Paste a JSON object or array in the input panel
  2. Set a variable name (defaults to data)
  3. Click Convert to Python or press Ctrl+Enter
  4. Copy the Python code or download as a .py file

Type Mapping

  • JSON null → Python None
  • JSON true/false → Python True/False
  • JSON integer → Python int
  • JSON float → Python float
  • JSON string → Python single-quoted string
  • JSON object → Python dict
  • JSON array → Python list

Frequently Asked Questions

Is this the same as json.loads()?

Functionally yes, but this tool gives you a static Python literal to paste directly into code. Use json.loads() at runtime for dynamic data; use this for hardcoded fixtures or notebooks.

How are strings with special characters handled?

Backslashes and single quotes inside strings are escaped. All strings are wrapped in single quotes to produce valid Python literals.

Does it support nested structures?

Yes. Nested JSON objects become nested Python dicts, and arrays of objects become lists of dicts, with full nesting depth.

Is the output PEP 8 formatted?

The output uses 4-space indentation consistent with PEP 8. You may want to run it through Black for auto-formatting on large structures.

Is my JSON uploaded anywhere?

No. Everything runs locally in your browser. Your data never leaves your machine.

Related Tools