JSON serialization and deserialization (marshalling and unmarshalling) in .NET - overview

The System.Text.Json namespace provides functionality for serializing to and deserializing from JavaScript Object Notation (JSON).

The library design emphasizes high performance and low memory allocation over an extensive feature set. Built-in UTF-8 support optimizes the process of reading and writing JSON text encoded as UTF-8, which is the most prevalent encoding for data on the web and files on disk.

The library also provides classes for working with an in-memory document object model (DOM). This feature enables random read-only access of the elements in a JSON file or string.

There are some limitations on what parts of the library that you can use from Visual Basic code. For more information, see Visual Basic support.

How to get the library

  • The library is built-in as part of the shared framework for .NET Core 3.0 and later versions.

  • For earlier framework versions, install the System.Text.Json NuGet package. The package supports:

    • .NET Standard 2.0 and later versions
    • .NET Framework 4.7.2 and later versions
    • .NET Core 2.0, 2.1, and 2.2

Security information

For information about security threats that were considered when designing JsonSerializer, and how they can be mitigated, see System.Text.Json Threat Model.

Thread safety

  • The System.Text.Json types are thread-safe, including:

Additional resources