Python Dict to JSON Converter
Convert a Python dict, list or repr() output to valid JSON: single quotes, True, False, None, tuples and triple-quoted strings are translated.
Free · No sign-up · Your inputs stay in your browser
Input
Convert a Python dict to JSON
Output
JSON
156 characters
Reads the repr Python prints: single quotes, True, False and None, tuples (which become arrays), triple-quoted strings and underscores in numbers. Objects such as datetime(...) or Decimal('1.5') have no literal form; convert them with json.dumps(obj, default=str) at the source.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Why print() output is not JSON
Printing a dict shows its repr, which uses single quotes and Python's own constants, so pasting it into a JSON tool fails on the first character. The right fix in code is json.dumps(data) rather than str(data); this converter is for the logs and notebooks where only the repr survived. Python's own ast.literal_eval() reads the same syntax safely.
Values with no literal form
Objects such as datetime(...), Decimal('1.5') or a class instance print as constructor calls, which are not literals and cannot be converted. Serialise them at the source with json.dumps(obj, default=str).