Skip to main content
Programming Language Tools

JSON to Python

Convert JSON into an equivalent Python dict/list literal, ready to paste directly into Python code.

Paste JSON below - this tool converts it into equivalent Python dict/list syntax, ready to paste into your code.

The only real differences between JSON and Python literal syntax are True/False/None (capitalized) versus JSON's lowercase true/false/null - this tool handles that conversion.

What Does This Tool Do?

It converts JSON into the equivalent Python literal syntax - primarily converting JSON's true/false/null into Python's True/False/None, since the rest of JSON and Python dict/list syntax is otherwise nearly identical.

Why Use This Tool?

Useful when you have a JSON API response or config and want to hardcode the equivalent data directly as a Python literal - for a test fixture, a script, or example data.

How to Use It

  1. Paste valid JSON.
  2. Click Convert.
  3. Copy the generated Python code.

Limitations

This produces a Python literal (dict/list/str/int/float/bool/None) - it does not generate a typed dataclass or Pydantic model; for that level of structure, review the JSON to TypeScript tool's approach as a model, adapted manually to Python's typing syntax.

Frequently Asked Questions

true/false become True/False, null becomes None, and objects and arrays become dicts and lists.

Yes, at runtime json.loads(text) does the same. This tool is useful when you want the data written directly in your Python source, for example in tests.

No. The conversion runs in your browser, so the JSON you paste stays on your device.
Share this tool: