Python Function Reference

json.loads

Convert a JSON string to a Python object.

Python 3.13
json.loads(s)

Parameters

sstr | bytes
A string containing JSON.

Return value

A Python object: a dict, list, string, number, bool or None.

Examples

JSON string to a dictionary

Python 3.13
import json

data = json.loads('{"name": "Anna", "langs": ["Python", "SQL"]}')
print(data['langs'][0])
Python

JSON types to Python types

Python 3.13
import json

print(json.loads('[1, 2.5, true, null]'))
[1, 2.5, True, None]

Details

Raises json.JSONDecodeError if the string is not valid JSON. JSON strings use only double quotes, so "{'a': 1}" cannot be parsed.

See also

Where to learn