JSON to Python dict converter

Handy when moving API payloads or config into Python code or pytest fixtures without keyword mistakes.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter json.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

Objects become dicts and arrays become lists, true, false and null become True, False and None, strings are quoted the way Python repr quotes them, and numbers keep their exact text.

Example

Result: Python dict: { 'name': 'Ali', 'age': 30, 'active': True, 'tags': [ 'admin', 'editor' ], 'address': { 'city': 'Riyadh', 'zip': None } }; Values converted: 7.

{
  "name": "Ali",
  "age": 30,
  "active": true,
  "tags": ["admin", "editor"],
  "address": {
    "city": "Riyadh",
    "zip": null
  }
}
{
    'name': 'Ali',
    'age': 30,
    'active': True,
    'tags': [
        'admin',
        'editor'
    ],
    'address': {
        'city': 'Riyadh',
        'zip': None
    }
}

Limits and caveats

  • The output is valid Python 3, though its layout can differ slightly from pprint.
  • Numbers such as 1e5 are kept as written, and Python reads them as floats.

Questions about this tool

Why not just use json.loads?

json.loads works at run time. This tool gives you a literal you can write straight into a .py file or test without reading a JSON file.

How are strings with quotes written?

Like Python repr: single quotes by default, double quotes when the string contains ' but no ".

Is key order kept?

Yes, and Python 3.7+ dicts keep insertion order as well.