Python Dict to JSON Converter

Paste a Python dict or list literal — `print(obj)` / `repr(obj)` output — and get valid JSON. Converts True/False/None, single quotes, tuples and sets, trailing commas and comments. Runs entirely in your browser, no server, no sign-up.

Try:
JSON

About this tool

Python's print() and repr() produce a dict/list literal, not JSON — so pasting it straight into a JSON parser fails. The syntaxes look alike but differ in ways a strict JSON reader rejects: Python writes True / False / None where JSON writes true / false / null, prefers 'single quotes', allows trailing commas, tuples (1, 2) and sets {1, 2}, # comments, and integer literals like 0xff or 1_000. This tool parses the Python literal and re-emits clean, valid JSON.

Everything runs locally in your browser via WebAssembly — nothing you paste leaves your machine.

Worked example

Input (a Python dict as printed by print(user)):

{'name': 'Ann', 'active': True, 'scores': (9, 8, 10), 'city': None}

Output (indent = 2 spaces):

{
  "name": "Ann",
  "active": true,
  "scores": [
    9,
    8,
    10
  ],
  "city": null
}

True became true, None became null, the single quotes became double quotes, and the tuple (9, 8, 10) became a JSON array.

What it converts

Options

Limits

FAQ

Why can't I just paste Python dict output into a JSON parser?

Because it isn't JSON. Python uses True/False/None, single quotes, tuples, sets, trailing commas and # comments — all of which a strict JSON parser rejects. This tool translates those Python-only conveniences into their JSON equivalents so the result parses everywhere.

What happens to tuples and sets?

Both become JSON arrays, since JSON has no tuple or set type. (1, 2, 3) and {1, 2, 3} each convert to [1, 2, 3]. A single parenthesized value without a trailing comma is not a tuple in Python — (5) is just 5 — so it converts to the bare value; write (5,) for a one-element array.

My dict has integer or boolean keys — is that valid?

JSON object keys must be strings, so non-string keys are stringified the same way Python's json.dumps does: {1: 'a', True: 'b', None: 'c'} becomes {"1": "a", "true": "b", "null": "c"}. Keys that are themselves tuples or lists can't be represented as JSON keys and will error.

Does it handle non-decimal numbers like `0xff` or `1_000`?

Yes. Hex (0xff), octal (0o17), binary (0b101) integer literals and underscore digit separators (1_000_000) are all parsed to their decimal value in the JSON output (255, 15, 5, 1000000). Complex numbers such as 3j have no JSON equivalent and are rejected with an error.

Is my data uploaded anywhere?

No. The conversion runs entirely in your browser through WebAssembly. Nothing you paste is sent to a server, logged, or stored.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool python-dict-to-json "{'name': 'Ann', 'active': True, 'scores': (9, 8, 10), 'tags': None}"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/python-dict-to-json/?input=%7B%27name%27%3A%20%27Ann%27%2C%20%27active%27%3A%20True%2C%20%27scores%27%3A%20%289%2C%208%2C%2010%29%2C%20%27tags%27%3A%20None%7D&indent=2&sort_keys=true&ensure_ascii=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.