Python ↔ JSON Converter

Convert Python dict/list literals to JSON, and back.

About this tool

Convert a Python dict/list literal — the kind you'd get from print(my_dict) or a scraped API response — into valid JSON, or the other way around. Handles single-quoted strings, True/False/None, tuples, nested structures, and Python comments.

Everything runs locally in your browser — nothing is uploaded.

Example

Python literal
{
    'name': 'Ada Lovelace',
    'active': True,
    'roles': ('admin', 'staff'),
    'score': None,  # not graded yet
}
JSON
{
  "name": "Ada Lovelace",
  "active": true,
  "roles": ["admin", "staff"],
  "score": null
}

Single quotes become double, True/False/None become true/false/null, the tuple becomes an array, and the trailing comma and # comment are dropped (JSON allows neither).

Frequently asked questions

Why isn't Python dict output valid JSON directly?
Python's repr()/print() output uses single quotes and the keywords True, False, and None instead of JSON's required double quotes and true/false/null — this tool translates between the two.
What happens to Python tuples?
Tuples (1, 2, 3) are converted to JSON arrays, since JSON has no separate tuple type. Converting JSON back to Python always produces lists, not tuples.
Does this evaluate f-strings or expressions?
No — this parses static literals only, not executable Python. An f-string like f"{x}" is read as a literal string containing the braces, not evaluated.