Python Dict / List to JSON

Converts a Python dict or list literal into JSON. None → null, True → true, False → false. Handles single-quoted strings and trailing commas. Nothing leaves your browser.

Private by architecture: All processing is 100% client-side memory. Your data never leaves this browser tab.
Python input
0 lines · 0 charsPython
JSON output
Ctrl/Cmd+Shift+C
0 charsJSON

About This Tool

Parses Python dict/list literal syntax into JSON. Normalizes common Python collection reprs from debuggers or print() (OrderedDict, defaultdict, Counter, and tuple/set/frozenset literals) into plain dict/list structures.

For the reverse direction, turning JSON into a Python literal you can paste into code, use JSON to Python Dict / List.

Key Features

  • Collection-repr normalization: OrderedDict, defaultdict, Counter, tuple, set, and frozenset literals convert to plain dict/list before parsing.
  • Variable-assignment stripping: Paste data = {...} directly; the leading assignment is detected and removed.
  • Live conversion: Output updates on every keystroke, plus Convert button and Ctrl/Cmd+Enter.
  • File upload: Load a .py or .txt file directly via the Upload button.
  • One-click swap: The swap button sends the JSON output to JSON to Python Dict / List.

Frequently Asked Questions

Does it handle single-quoted strings?
Yes: Python single-quoted strings are normalised to JSON double-quoted strings automatically.
What about trailing commas?
Trailing commas (common in Python literals) are stripped before parsing.
Can I paste a variable assignment like data = {...}?
Yes: the leading assignment is detected and stripped, so you can paste Python source directly.
Can I go the other direction (JSON to Python dict)?
Yes: use the JSON to Python Dict / List tool.