# Python JSON libraries

Python JSON libraries convert JSON text into Python objects and write Python objects back out as JSON. A parser either reads the whole document into memory at once or yields one item at a time from a stream. These libraries let APIs, data pipelines, and AI agents exchange structured data with other services.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Jiter](#jiter) | 433.6M | Not on GitHub | Nov 2026 | MIT |
| [orjson](#orjson) | 225.6M | 8.3K | Oct 2026 | MPL-2.0 AND (Apache-2.0 OR MIT) |
| [json5](#jsonfive) | 51.5M | Not on GitHub | Oct 2026 | Apache-2.0 |
| [simplejson](#simplejson) | 50.9M | Not on GitHub | Nov 2026 | MIT OR AFL-2.1 |
| [ijson](#ijson) | 48.5M | Not on GitHub | Oct 2026 | BSD-3-Clause AND ISC |
| [msgspec](#msgspec) | 40.5M | 4.2K | Sep 2026 | BSD-3-Clause |
| [UltraJSON](#ujson) | 30.4M | Not on GitHub | Nov 2026 | BSD-3-Clause AND TCL |
| [jsonpickle](#jsonpickle) | 16.6M | Not on GitHub | Oct 2026 | BSD-3-Clause |

Downloads: pypi, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Jiter](#jiter) has the most monthly downloads in this comparison, at 433.6M, a count that includes installs as a Pydantic dependency.

## Capabilities

| Library | Native JSON encoding | Lazy item parsing | Typed schema decoding |
| --- | --- | --- | --- |
| [Jiter](#jiter) | No | No | No |
| [orjson](#orjson) | Yes | No | No |
| [json5](#jsonfive) | Yes | No | No |
| [simplejson](#simplejson) | Yes | No | No |
| [ijson](#ijson) | No | Yes | No |
| [msgspec](#msgspec) | Yes | No | Yes |
| [UltraJSON](#ujson) | Yes | No | No |
| [jsonpickle](#jsonpickle) | Yes | No | No |

## Libraries

### Jiter

[GitHub](https://github.com/pydantic/jiter) · [pypi](https://pypi.org/project/jiter) · [Docs](https://api.github.com/repos/pydantic/jiter/contents/crates/jiter-python/README.md?ref=v0.19.0)

Parses JSON iteratively.

- Downloads / mo: 433.6M
- Last release: 0.19.0
- License: MIT
- Capabilities: [From the Jiter docs](https://api.github.com/repos/pydantic/jiter/contents/crates/jiter-python/README.md?ref=v0.19.0)

```sh
python -m pip install jiter==0.19.0
```

**openai/openai-python** (32.2K stars)

[openai/openai-python](https://github.com/openai/openai-python) 

```python
def _accumulate_chunk(self, chunk: ChatCompletionChunk) -> ParsedChatCompletionSnapshot:
    completion_snapshot = self.__current_completion_snapshot

    if completion_snapshot is None:
        return _convert_initial_chunk_into_snapshot(chunk)

    for choice in chunk.choices:
        try:
            choice_snapshot = completion_snapshot.choices[choice.index]
            previous_tool_calls = choice_snapshot.message.tool_calls or []

            choice_snapshot.message = cast(
                ParsedChatCompletionMessageSnapshot,
                construct_type(
                    type_=ParsedChatCompletionMessageSnapshot,
                    value=accumulate_delta(
                        cast(
                            "dict[object, object]",
                            model_dump(
                                choice_snapshot.message,
                                # we don't want to serialise / deserialise our custom properties
                                # as they won't appear in the delta and we don't want to have to
                                # continuously reparse the content
                                exclude={
                                    "parsed": True,
                                    "tool_calls": {
                                        idx: {"function": {"parsed_arguments": True}}
                                        for idx, _ in enumerate(choice_snapshot.message.tool_calls or [])
                                    },
                                },
                            ),
                        ),
                        cast("dict[object, object]", choice.delta.to_dict()),
                    ),
                ),
            )

            # ensure tools that have already been parsed are added back into the newly
            # constructed message snapshot
            for tool_index, prev_tool in enumerate(previous_tool_calls):
                new_tool = (choice_snapshot.message.tool_calls or [])[tool_index]

                if prev_tool.type == "function":
                    assert new_tool.type == "function"
                    new_tool.function.parsed_arguments = prev_tool.function.parsed_arguments
                elif TYPE_CHECKING:
                    assert_never(prev_tool)
        except IndexError:
            choice_snapshot = cast(
                ParsedChoiceSnapshot,
                construct_type(
                    type_=ParsedChoiceSnapshot,
                    value={
                        **choice.model_dump(exclude_unset=True, exclude={"delta"}),
                        "message": accumulate_delta({}, cast("dict[object, object]", choice.delta.to_dict())),
                    },
                ),
            )
            completion_snapshot.choices.append(choice_snapshot)

        if choice.finish_reason:
            choice_snapshot.finish_reason = choice.finish_reason

            if has_parseable_input(response_format=self._response_format, input_tools=self._input_tools):
                if choice.finish_reason == "length":
                    # at the time of writing, `.usage` will always be `None` but
                    # we include it here in case that is changed in the future
                    raise LengthFinishReasonError(completion=completion_snapshot)

                if choice.finish_reason == "content_filter":
                    raise ContentFilterFinishReasonError(completion=completion_snapshot)

        if (
            choice_snapshot.message.content
            and not choice_snapshot.message.refusal
            and is_given(self._rich_response_format)
            # partial parsing fails on white-space
            and choice_snapshot.message.content.lstrip()
        ):
            choice_snapshot.message.parsed = from_json(
                bytes(choice_snapshot.message.content, "utf-8"),
                partial_mode=True,
            )

        for tool_call_chunk in choice.delta.tool_calls or []:
            tool_call_snapshot = (choice_snapshot.message.tool_calls or [])[tool_call_chunk.index]

            if tool_call_snapshot.type == "function":
                input_tool = get_input_tool_by_name(
                    input_tools=self._input_tools, name=tool_call_snapshot.function.name
                )

                if (
                    input_tool
                    and input_tool.get("function", {}).get("strict")
                    and tool_call_snapshot.function.arguments
                ):
                    tool_call_snapshot.function.parsed_arguments = from_json(
                        bytes(tool_call_snapshot.function.arguments, "utf-8"),
                        partial_mode=True,
                    )
            elif TYPE_CHECKING:
                assert_never(tool_call_snapshot)

        if choice.logprobs is not None:
            if choice_snapshot.logprobs is None:
                choice_snapshot.logprobs = build(
                    ChoiceLogprobs,
                    content=choice.logprobs.content,
                    refusal=choice.logprobs.refusal,
                )
            else:
                if choice.logprobs.content:
                    if choice_snapshot.logprobs.content is None:
                        choice_snapshot.logprobs.content = []

                    choice_snapshot.logprobs.content.extend(choice.logprobs.content)

                if choice.logprobs.refusal:
                    if choice_snapshot.logprobs.refusal is None:
                        choice_snapshot.logprobs.refusal = []

                    choice_snapshot.logprobs.refusal.extend(choice.logprobs.refusal)

    completion_snapshot.usage = chunk.usage
    completion_snapshot.system_fingerprint = chunk.system_fingerprint
    if chunk.moderation is not None:
        completion_snapshot.moderation = cast(
            Moderation, construct_type(type_=Moderation, value=chunk.moderation.to_dict())
        )

    return completion_snapshot
```

[src/openai/lib/streaming/chat/_completions.py](https://github.com/openai/openai-python/blob/0d50c9daece1a4a0f4920f64b5ff90846b4e2050/src/openai/lib/streaming/chat/_completions.py#L362-L493) · [More projects using Jiter →](https://dashboard.exa.ai/playground/search?q=jiter%20GitHub%20projects)

**Quickstart**

```python
import jiter

data = jiter.from_json(b'{"name":"John","age":30}')

```

From [README.md](https://api.github.com/repos/pydantic/jiter/contents/crates/jiter-python/README.md?ref=v0.19.0)

### orjson

[GitHub](https://github.com/ijl/orjson) · [pypi](https://pypi.org/project/orjson) · [Docs](https://api.github.com/repos/ijl/orjson/readme)

Provides a JSON serialization library for Python.

- Downloads / mo: 225.6M
- Stars: 8.3K
- Last release: 3.13.0
- License: MPL-2.0 AND (Apache-2.0 OR MIT)
- Capabilities: [From the orjson docs](https://api.github.com/repos/ijl/orjson/readme)

**Strengths**

- **Serializes native scientific data.** Enable the NumPy option to serialize supported array values.
- **Handles structured Python values.** Serialize dataclasses, datetimes, NumPy arrays, and UUID values.

**Watch out for**

- **Integers have fixed bounds.** Default integer serialization uses the documented native integer range.
- **File I/O needs application code.** Read or write files separately from the JSON codec.

```sh
python -m pip install orjson==3.13.0
```

**zauberzeug/nicegui** (16.3K stars)

[zauberzeug/nicegui](https://github.com/zauberzeug/nicegui) 

```python
def dumps(obj: Any,
          sort_keys: bool = False,
          separators: tuple[str, str] | None = None, *,
          indent: bool = False) -> str:
    """Serializes a Python object to a JSON-encoded string.

    By default, this function supports serializing NumPy arrays, which Python's json module does not.

    Uses package ``orjson`` internally.
    """
    # note that parameters `sort_keys` and `separators` are required by AsyncServer's
    # internal calls, which match Python's default `json.dumps` API.
    assert separators is None or separators == (',', ':'), \
        f'NiceGUI JSON serializer only supports Python\'s default JSON separators "," and ":", but got {separators} instead.'

    opts = ORJSON_OPTS

    # flag for sorting by object keys
    if sort_keys:
        opts |= orjson.OPT_SORT_KEYS

    # flag for pretty-printing with indentation
    if indent:
        opts |= orjson.OPT_INDENT_2

    return orjson.dumps(obj, option=opts, default=_orjson_converter).decode('utf-8')

```

[nicegui/json/orjson_wrapper.py](https://github.com/zauberzeug/nicegui/blob/884eb1c38e58f976bce451d4e19cf898b78dfefa/nicegui/json/orjson_wrapper.py) · [More projects using orjson →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20orjson%20for%20web-response%20serialization%2C%20typed%20model%20payloads%2C%20custom%20object%20conversion%20and%20decimal-safe%20JSON%20processing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import orjson

data = orjson.loads(b'{"name":"Ada"}')

```

From [README.md](https://api.github.com/repos/ijl/orjson/readme)

### json5

[GitHub](https://github.com/dpranke/pyjson5) · [pypi](https://pypi.org/project/json5) · [Docs](https://api.github.com/repos/dpranke/pyjson5/readme)

Reads and writes the JSON5 data format.

- Downloads / mo: 51.5M
- Last release: 0.17.3
- License: Apache-2.0
- Capabilities: [From the json5 docs](https://api.github.com/repos/dpranke/pyjson5/readme)

```sh
python -m pip install json5==0.17.3
```

**jupyterlab/jupyterlab_server** (154 stars)

[jupyterlab/jupyterlab_server](https://github.com/jupyterlab/jupyterlab_server) 

```python
def load_config(path: str) -> Any:
    """Load either a json5 or a json config file.

    Parameters
    ----------
    path : str
        Path to the file to be loaded

    Returns
    -------
    Dict[Any, Any]
        Dictionary of json or json5 data
    """
    with open(path, encoding="utf-8") as fid:
        if path.endswith(".json5"):
            return json5.load(fid)
        return json.load(fid)
```

[jupyterlab_server/config.py](https://github.com/jupyterlab/jupyterlab_server/blob/475cfc19e0e69444fc7e3b0e41655cbeb32a8756/jupyterlab_server/config.py#L95-L111) · [More projects using json5 →](https://dashboard.exa.ai/playground/search?q=json5%20GitHub%20projects)

**Quickstart**

```python
import json5

data = json5.loads("{name: 'Ada',}")

```

From [README.md](https://api.github.com/repos/dpranke/pyjson5/readme)

### simplejson

[GitHub](https://github.com/simplejson/simplejson) · [pypi](https://pypi.org/project/simplejson) · [Docs](https://simplejson.readthedocs.io/en/latest/)

Encodes and decodes JSON with an extensible API.

- Downloads / mo: 50.9M
- Last release: 4.3.0
- License: MIT OR AFL-2.1
- Capabilities: [From the simplejson docs](https://simplejson.readthedocs.io/en/latest/)

```sh
python -m pip install simplejson==4.3.0
```

**psf/requests** (54.3K stars)

[psf/requests](https://github.com/psf/requests) 

```python
def json(self, **kwargs: Any) -> Any:
    r"""Decodes the JSON response body (if any) as a Python object.

    This may return a dictionary, list, etc. depending on what is in the response.

    :param \*\*kwargs: Optional arguments that ``json.loads`` takes.
    :raises requests.exceptions.JSONDecodeError: If the response body does not
        contain valid json.
    """

    if not self.encoding and self.content and len(self.content) > 3:
        # No encoding set. JSON RFC 4627 section 3 states we should expect
        # UTF-8, -16 or -32. Detect which one to use; If the detection or
        # decoding fails, fall back to `self.text` (using charset_normalizer to make
        # a best guess).
        encoding = guess_json_utf(self.content)
        if encoding is not None:
            try:
                return complexjson.loads(self.content.decode(encoding), **kwargs)
            except UnicodeDecodeError:
                # Wrong UTF codec detected; usually because it's not UTF-8
                # but some other 8-bit codec.  This is an RFC violation,
                # and the server didn't bother to tell us what codec *was*
                # used.
                pass
            except JSONDecodeError as e:
                raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

    try:
        return complexjson.loads(self.text, **kwargs)
    except JSONDecodeError as e:
        # Catch JSON-related errors and raise as requests.JSONDecodeError
        # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
        raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
```

[src/requests/models.py](https://github.com/psf/requests/blob/3c7baaa05ab4aa49cc819ce3a819d260de19c157/src/requests/models.py#L1091-L1124) · [More projects using simplejson →](https://dashboard.exa.ai/playground/search?q=simplejson%20GitHub%20projects)

**Quickstart**

```python
import simplejson

encoded = simplejson.dumps({"ready": True})

```

From [index.html](https://simplejson.readthedocs.io/en/latest/)

### ijson

[GitHub](https://github.com/ICRAR/ijson) · [pypi](https://pypi.org/project/ijson) · [Docs](https://api.github.com/repos/ICRAR/ijson/readme)

Parses JSON through standard Python iterators.

- Downloads / mo: 48.5M
- Last release: 3.6.0
- License: BSD-3-Clause AND ISC
- Capabilities: [From the ijson docs](https://api.github.com/repos/ICRAR/ijson/readme)

```sh
python -m pip install ijson==3.6.0
```

**datahub-project/datahub** (13.0K stars)

[datahub-project/datahub](https://github.com/datahub-project/datahub) 

```python
def _iterate_file_streaming(self, fp: Any) -> Iterable[Any]:
    # Count the number of elements in the file.
    if self.config.count_all_before_starting:
        count_start_time = datetime.datetime.now()
        parse_stream = ijson.parse(fp, use_float=True)
        total_elements = 0
        for _row in ijson.items(parse_stream, "item", use_float=True):
            total_elements += 1
        count_end_time = datetime.datetime.now()
        self.report.add_count_time(count_end_time - count_start_time)
        self.report.current_file_num_elements = total_elements
        fp.seek(0)

    # Read the file.
    self.report.current_file_elements_read = 0
    parse_start_time = datetime.datetime.now()
    parse_stream = ijson.parse(fp, use_float=True)
    for row in ijson.items(parse_stream, "item", use_float=True):
        parse_end_time = datetime.datetime.now()
        self.report.add_parse_time(parse_end_time - parse_start_time)
        self.report.current_file_elements_read += 1
        yield row
```

[metadata-ingestion/src/datahub/ingestion/source/file.py](https://github.com/datahub-project/datahub/blob/047c7e6a7095c7dfbe4513b769837df1144cbeda/metadata-ingestion/src/datahub/ingestion/source/file.py#L294-L315) · [More projects using ijson →](https://dashboard.exa.ai/playground/search?q=ijson%20GitHub%20projects)

**Quickstart**

```python
from io import BytesIO
import ijson

source = BytesIO(b'[{"name":"Ada"}]')
item = next(ijson.items(source, "item"))

```

From [README.rst](https://api.github.com/repos/ICRAR/ijson/readme)

### msgspec

[GitHub](https://github.com/msgspec/msgspec) · [pypi](https://pypi.org/project/msgspec) · [Docs](https://api.github.com/repos/msgspec/msgspec/readme)

Provides serialization and data validation with JSON support.

- Downloads / mo: 40.5M
- Stars: 4.2K
- Last release: 0.22.0
- License: BSD-3-Clause
- Capabilities: [From the msgspec docs](https://api.github.com/repos/msgspec/msgspec/readme)

**Strengths**

- **Validates typed decoded data.** Pass a schema type when decoding a message.
- **Adapts custom application types.** Use encoding and decoding hooks for types outside native support.

**Watch out for**

- **Construction does not validate types.** Use a typed decoder when input field types must be checked.

```sh
python -m pip install msgspec==0.22.0
```

**litestar-org/litestar** (8.6K stars)

[litestar-org/litestar](https://github.com/litestar-org/litestar) 

```python
def decode_json(  # type: ignore[misc]
    value: str | bytes,
    target_type: type[T] | EmptyType = Empty,
    type_decoders: TypeDecodersSequence | None = None,
    strict: bool = True,
) -> Any:
    """Decode a JSON string/bytes into an object.

    Args:
        value: Value to decode
        target_type: An optional type to decode the data into
        type_decoders: Optional sequence of type decoders
        strict: Whether type coercion rules should be strict. Setting to False enables
            a wider set of coercion rules from string to non-string types for all values

    Returns:
        An object

    Raises:
        SerializationException: If error decoding ``value``.
    """
    try:
        if target_type is Empty:
            return _msgspec_json_decoder.decode(value)
        return msgspec.json.decode(
            value,
            dec_hook=partial(
                default_deserializer,
                type_decoders=type_decoders,
            ),
            type=target_type,
            strict=strict,
        )
    except msgspec.DecodeError as msgspec_error:
        raise SerializationException(str(msgspec_error)) from msgspec_error
```

[litestar/serialization/msgspec_hooks.py](https://github.com/litestar-org/litestar/blob/16ef4933c5576944cbbf3f72676382c4a5685af7/litestar/serialization/msgspec_hooks.py#L188-L222) · [More projects using msgspec →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20msgspec%20for%20web-response%20serialization%2C%20typed%20model%20payloads%2C%20custom%20object%20conversion%20and%20decimal-safe%20JSON%20processing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import msgspec

class User(msgspec.Struct):
    name: str

user = msgspec.json.decode(b'{"name":"Ada"}', type=User)

```

From [README.md](https://api.github.com/repos/msgspec/msgspec/readme)

### UltraJSON

[GitHub](https://github.com/ultrajson/ultrajson) · [pypi](https://pypi.org/project/ujson) · [Docs](https://api.github.com/repos/ultrajson/ultrajson/readme)

Encodes and decodes JSON.

- Downloads / mo: 30.4M
- Last release: 6.1.0
- License: BSD-3-Clause AND TCL
- Capabilities: [From the UltraJSON docs](https://api.github.com/repos/ultrajson/ultrajson/readme)

```sh
python -m pip install ujson==6.1.0
```

**sanic-org/sanic** (18.6K stars)

[sanic-org/sanic](https://github.com/sanic-org/sanic) 

```python
def json(
    body,
    status=200,
    headers=None,
    content_type="application/json",
    dumps=json_dumps,
    **kwargs
):
    """
    Returns response object with body in json format.

    :param body: Response data to be serialized.
    :param status: Response code.
    :param headers: Custom Headers.
    :param kwargs: Remaining arguments that are passed to the json encoder.
    """
    return HTTPResponse(
        dumps(body, **kwargs),
        headers=headers,
        status=status,
        content_type=content_type,
    )
```

[sanic/response.py](https://github.com/sanic-org/sanic/blob/bc7d0f0da57e6b0d6c7d57ca3bb9d0dda66a7199/sanic/response.py#L203-L224) · [More projects using UltraJSON →](https://dashboard.exa.ai/playground/search?q=ujson%20GitHub%20projects)

**Quickstart**

```python
import ujson

encoded = ujson.dumps([{"key": "value"}, 81, True])

```

From [README.md](https://api.github.com/repos/ultrajson/ultrajson/readme)

### jsonpickle

[GitHub](https://github.com/jsonpickle/jsonpickle) · [pypi](https://pypi.org/project/jsonpickle) · [Docs](https://api.github.com/repos/jsonpickle/jsonpickle/readme)

Encodes and decodes any Python object to and from JSON.

- Downloads / mo: 16.6M
- Last release: 4.1.4
- License: BSD-3-Clause
- Capabilities: [From the jsonpickle docs](https://api.github.com/repos/jsonpickle/jsonpickle/readme)

```sh
python -m pip install jsonpickle==4.1.4
```

**koalalorenzo/python-digitalocean** (1.3K stars)

[koalalorenzo/python-digitalocean](https://github.com/koalalorenzo/python-digitalocean) 

```python
def create(self, *args, **kwargs):
    inbound = jsonpickle.encode(self.inbound_rules, unpicklable=False)
    outbound = jsonpickle.encode(self.outbound_rules, unpicklable=False)
    params = {'name': self.name,
              'droplet_ids': self.droplet_ids,
              'inbound_rules': jsonpickle.decode(inbound),
              'outbound_rules': jsonpickle.decode(outbound),
              'tags': self.tags}

    data = self.get_data('firewalls/', type=POST, params=params)

    if data:
        self._set_firewall_attributes(data)

    return self
```

[digitalocean/Firewall.py](https://github.com/koalalorenzo/python-digitalocean/blob/3d802463be6220ab044dc1e5d381c93e94365ac4/digitalocean/Firewall.py#L182-L196) · [More projects using jsonpickle →](https://dashboard.exa.ai/playground/search?q=jsonpickle%20GitHub%20projects)

**Quickstart**

```python
from dataclasses import dataclass
import jsonpickle

@dataclass
class Example:
    data: str

encoded = jsonpickle.encode(Example("value1"))

```

From [README.rst](https://api.github.com/repos/jsonpickle/jsonpickle/readme)

## FAQ

### Which Python JSON library should I use?

[orjson](#orjson) suits applications that encode dataclasses, datetimes, and NumPy arrays to JSON bytes. [msgspec](#msgspec) suits code that decodes JSON into declared types with validation. [ijson](#ijson) suits large files and streams that should be read one item at a time.

### What is orjson?

[orjson](#orjson) is a JSON library with native support for dataclasses, datetimes, and NumPy arrays. Its encoder returns bytes rather than a string.

### What is Jiter?

[Jiter](#jiter) is a JSON parser that turns bytes into Python objects, with modes for partial input. It parses only and has no JSON encoder.

### Which Python JSON parser reads a stream one item at a time?

[ijson](#ijson) parses a JSON stream incrementally and yields events or items through standard Python iterators. The calling code decides how many of those items stay in memory.

### What is UltraJSON?

[UltraJSON](#ujson) is a JSON encoder and decoder in maintenance-only mode. Its maintainers continue new Python support and critical fixes and encourage users to migrate to other libraries.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python JSON libraries json orjson msgspec python-rapidjson examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
