How to convert a Python dict to JSON
- Paste a dictionary or list copied from print() output or the PDB debugger.
- Choose Python literal as source and JSON as target, or swap them to get Python back.
- Select Convert, then copy result.
Parsed, never executed
The converter reads a limited literal grammar and never calls Python or eval. String keys, nested dictionaries, lists, tuples, finite numbers, booleans, and None are supported. Sets, bytes, function calls, and other expressions are rejected.
Python literal vs JSON syntax
| Python | JSON |
|---|---|
True / False | true / false |
None | null |
'text' | "text" |
(1, 2) | [1, 2] |
JSON requires double-quoted keys and strings. Tuples become arrays, so converting back yields a list.