Boneyard Tools

JSON to Python Dict Converter

Paste JSON and get a ready-to-paste Python literal you can drop straight into a script. Objects become dicts, arrays become lists, and the JSON keywords true, false and null are rewritten as Python's True, False and None. Strings keep single quotes by default, with backslashes, quotes and newlines escaped so the literal parses cleanly.

How to convert JSON to a Python dict

  1. Paste or type your JSON into the JSON input box, or click Load sample to see a worked example.
  2. Open the Quotes menu and pick Single (Python's usual style) or Double.
  3. Set Indent to 2 spaces or 4 spaces to match your codebase.
  4. Read the formatted literal in the Python dict box below.
  5. Click Copy and paste it directly into your Python file.

Examples

Object with a list and null

{"name":"Ada","items":[1,2],"note":null}
{
  'name': 'Ada',
  'items': [
    1,
    2,
  ],
  'note': None,
}

Booleans and a float become True, False and a number

{"x":1.5,"live":false,"note":null}
{
  'x': 1.5,
  'live': False,
  'note': None,
}

Double-quote style with a nested list

{"tags":["a","b"]}
{
  "tags": [
    "a",
    "b",
  ],
}

Frequently asked questions

Is my JSON uploaded anywhere?

No. The conversion runs entirely in your browser using client-side JavaScript, so your data never touches a server and never leaves your device. That makes it safe for config files, API responses and other sensitive payloads.

How are true, false and null converted?

They map to Python's True, False and None respectively. This is the core reason raw JSON is not directly valid as a Python literal: Python capitalizes its booleans and uses None instead of null.

Should I choose single or double quotes for strings?

Either is valid Python. Single quotes are the more common convention and the default here, matching tools like Black. Pick double quotes if your project standardizes on them or if your strings frequently contain apostrophes.

Is the output safe to paste into code?

Yes. Backslashes are doubled, the active quote character is escaped, and newlines, carriage returns and tabs inside strings become the \n, \r and \t sequences. The result is a literal that Python parses without a syntax error.

Can I read the output back with json.loads?

No. The output is Python source, not JSON, because of True, False, None and single quotes. To read it back at runtime use ast.literal_eval, which safely parses a Python literal, or paste it straight into your code as a value.

What happens to a top-level array?

A JSON array at the top level becomes a Python list rather than a dict. Every element is rendered recursively, so nested objects inside the array still turn into dicts with the same indentation rules.

How is indentation handled for nested structures?

Each level of nesting adds the indent width you chose (2 or 4 spaces). Dicts and lists print one entry per line with a trailing comma, which keeps deep structures readable and produces clean diffs in version control.

What if my JSON is invalid?

The tool tries to parse the input first. If it is not valid JSON, you get an error message describing the problem instead of a broken literal, so you can fix the source before copying.

Are numbers or floats changed?

Numbers pass through as their JSON text form, so 1.5 stays 1.5 and 42 stays 42. Python and JSON share the same numeric syntax for these cases, so no conversion is needed.

Learn more

Related tools