Python dict to JSON converter

Python dict → JSON by default; switch modes for JSON → Python. Auto-converts as you type—private in your browser.

  • 100% in your browser
  • Python dict → JSON default
  • Copy either pane
  • Trailing commas OK (JSON)
Python Dict Input
JSON Output
JSON ↔ Python type mapping
JSONPython
true / falseTrue / False
nullNone
"double quotes"'single quotes'

How this tool fits your workflow

More in this category →

JSON and Python dicts: subtle but critical differences

JSON and Python dictionaries look nearly identical, which is why copying a Python dict into a JSON field — or vice versa — causes so many bugs. JSON requires double-quoted string keys and uses lowercase true, false, and null. Python dictionaries accept single or double quotes and use capitalized True, False, and None.

These differences matter in practice: pasting a Python API response example into a JSON config file breaks the parser. Pasting JSON into a Python script that expects native types means you get the string "true" instead of the boolean True. This converter handles both directions automatically, replacing each literal and quoting convention with the correct target format.

Beyond literals, the converter handles nested structures — objects inside objects, arrays of dicts, mixed types — recursively. You do not need to manually walk through a complex payload to swap out every True or null.

When you need this converter

API documentation teams often write examples in Python and need to convert them to JSON for OpenAPI specs or Postman collections. Data engineers who prototype in Python notebooks frequently need to export config dicts as JSON for downstream systems. Backend developers debug by copying API responses — which are JSON — into Python REPLs, needing the inverse conversion.

Configuration files are another common source of friction. Infrastructure-as-code tools like Ansible use YAML with Python-like booleans, while Terraform uses JSON. A quick paste-and-convert step removes a manual editing chore that is easy to get wrong under time pressure.

How the conversion works

For JSON to Python dict: the converter parses the JSON string, then serializes it as a Python literal — replacing true with True, false with False, null with None, and double-quoted keys with either single or double-quoted strings depending on content.

For Python dict to JSON: the converter evaluates the Python literal syntax, maps Python literals to their JSON equivalents, and outputs a formatted JSON string with double-quoted keys and standard JSON types. Trailing commas — valid in Python but not in JSON — are stripped automatically before parsing.

All processing runs in your browser. No data is uploaded. The tool is especially useful for developers who work across language boundaries and need a fast way to translate between two formats that look identical but differ in the details that matter most.

Frequently asked questions

What is the difference between JSON and a Python dictionary?
JSON uses double-quoted string keys, true/false/null literals, and is a text format. Python dictionaries use single or double quotes, True/False/None literals, and are native Python objects. This tool converts between both formats automatically.
Can this converter handle nested objects?
Yes. The converter handles nested objects, arrays, and any depth of nesting. It recursively processes the structure and outputs the correct Python or JSON representation.
Is my data sent to a server?
No. All conversion runs in your browser with JavaScript. Your data is never uploaded or stored anywhere.
Why does my Python dict fail to convert to JSON?
Common issues include Python-specific literals (True, False, None) instead of JSON literals (true, false, null), single-quoted strings instead of double-quoted ones, and trailing commas. Paste your dict into the converter and it will handle these transformations automatically.