Python Dict to JSON Converter

Paste a Python dict - None, True/False, single quotes, tuples and all - and get valid JSON back.

Detected: Python dict
Input (auto-detected)
Convert to
💡 Pro tip: PressKto quickly search and navigate between tools

Examples & Use Cases

  • Before:

    A long single-line dict with single quotes, True/False/None and maybe a tuple or two - valid Python, invalid JSON.

  • After:

    Formatted JSON with double-quoted keys and the right literals, ready to drop into a request body, a fixture file or an API doc.

The usual reason people need this: the object exists only as text in a terminal.

A dict printed to the console
print(response) and repr() give you Python syntax, which no JSON tool will accept.
  • Before:

    Copying the dict out of the source file and rewriting the quotes and keywords by hand, one line at a time.

  • After:

    A JSON file with the same structure, produced in one step, so the fixture cannot drift from the dict it was taken from.

Keeps fixtures honest without a throwaway script.

Turning a dict into a test fixture
Test suites and mock servers often want a .json file where the code has a dict literal.

Frequently Asked Questions

Yes, both become JSON arrays. That matches json.dumps() for tuples, and it is more forgiving for sets, which json.dumps() raises a TypeError on. Empty set() and frozenset() become empty arrays.