JSON to Python Dict Converter
Converts JSON into Python dictionary syntax and reads Python dict literals back into JSON. The three literals that differ between the languages — true, false and null — become True, False and None, which is exactly the edit that makes a pasted JSON blob fail in a Python file.
Useful for building fixtures, test data and default configuration from a real API response.
How to use it
- Paste JSON on the left to produce a Python dict literal.
- Press Swap to convert a Python dict back into JSON.
- Single-quoted strings and trailing commas are handled when reading Python.
What changes between the two
Beyond the three literals, JSON string escaping is a subset of Python's, so strings can be emitted unchanged and remain valid. Special float values are handled explicitly: NaN and infinity become float('nan') and float('inf') on the way out, since JSON cannot represent either.
Reading Python back into JSON reuses the same repair engine that powers the JSON parser, so single quotes, trailing commas and the Python literals are all normalised safely without touching the contents of your strings.
Frequently asked questions
Why does my pasted JSON fail in Python?
- Almost always because of true, false and null, which Python spells True, False and None. Converting here fixes exactly that.
Can I paste a dict that uses single quotes?
- Yes. Single-quoted strings, trailing commas and Python's literals are all understood, and string contents are preserved exactly.
What about tuples, sets or datetime objects?
- Those have no JSON equivalent and are not supported. Convert them to lists, arrays or ISO strings in Python before converting.