Python dict to JSON
Convert a Python dictionary or list to JSON, and back again.
Python dict to JSON
Paste a Python dictionary or list and this tool converts it to valid JSON — turning True, False and None into true, false and null, and single-quoted strings into double-quoted ones. It also parses Python tuples, since JSON has no tuple type of its own, folding them into JSON arrays. Use it when you copied a variable's value out of a Python REPL, a print() call, or a pprint dump and need the equivalent JSON for an API request, a config file, or a test fixture.
Switch the direction to go the other way, from JSON to Python: object keys and strings render with the quote style you choose (single by default, matching PEP 8, or double), and JSON arrays render as Python lists unless you turn on "Render arrays as tuples". Sort keys alphabetically for a stable diff, or leave the original order in place. Indent with 2 spaces, 4 spaces, a tab, or collapse everything onto one compact line. Turning on "Convert date() / datetime() values" recognizes date(...) and datetime(...) calls in Python input and writes them out as ISO 8601 strings, and does the reverse for JSON strings that already look like an ISO date or timestamp.
The parser accepts both single and double-quoted strings, nested dicts, lists and tuples of any depth, negative numbers, underscores in integers (1_000) and scientific notation. Windows and Unix line endings are treated the same, and the tally under the output reports the key count, line count and character count as you type. If the input isn't valid Python or JSON, the error message points at the exact line and column.
Everything runs locally in your browser — nothing you paste is uploaded anywhere. Copy the result, download it as a .txt file, or send the output straight back into the input to keep converting.