Microsoft.AspNetCore.JsonPatch 10.0.0

About

Microsoft.AspNetCore.JsonPatch provides ASP.NET Core support for JSON PATCH requests.

How to Use

To use Microsoft.AspNetCore.JsonPatch, follow these steps:

Installation

dotnet add package Microsoft.AspNetCore.JsonPatch
dotnet add package Microsoft.AspNetCore.Mvc.NewtonsoftJson

Configuration

To enable JSON Patch support, call AddNewtonsoftJson in your ASP.NET Core app's Program.cs:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers()
    .AddNewtonsoftJson();

Configure when using System.Text.Json

To add support for JSON Patch using Newtonsoft.Json while continuing to use System.Text.Json for other input and output formatters:

  1. Update your Program.cs with logic to construct a NewtonsoftJsonPatchInputFormatter:
    static NewtonsoftJsonPatchInputFormatter GetJsonPatchInputFormatter()
    {
        var builder = new ServiceCollection()
            .AddLogging()
            .AddMvc()
            .AddNewtonsoftJson()
            .Services.BuildServiceProvider();
    
        return builder
            .GetRequiredService<IOptions<MvcOptions>>()
            .Value
            .InputFormatters
            .OfType<NewtonsoftJsonPatchInputFormatter>()
            .First();
    }
    
  2. Configure the input formatter:
    var builder = WebApplication.CreateBuilder(args);
    
    builder.Services.AddControllers(options =>
    {
        options.InputFormatters.Insert(0, GetJsonPatchInputFormatter());
    });
    

Usage

To define an action method for a JSON Patch in an API controller:

  1. Annotate it with the HttpPatch attribute
  2. Accept a JsonPatchDocument<TModel>
  3. Call ApplyTo on the patch document to apply changes

For example:

[HttpPatch]
public IActionResult JsonPatchWithModelState(
    [FromBody] JsonPatchDocument<Customer> patchDoc)
{
    if (patchDoc is not null)
    {
        var customer = CreateCustomer();

        patchDoc.ApplyTo(customer, ModelState);

        if (!ModelState.IsValid)
        {
            return BadRequest(ModelState);
        }

        return new ObjectResult(customer);
    }
    else
    {
        return BadRequest(ModelState);
    }
}

In a real app, the code would retrieve the data from a store such as a database and update the database after applying the patch.

Additional Documentation

For additional documentation and examples, refer to the official documentation on JSON Patch in ASP.NET Core.

Feedback & Contributing

Microsoft.AspNetCore.JsonPatch is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on Microsoft.AspNetCore.JsonPatch.

Packages Downloads
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
38
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
39
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
42
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
44
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
39
Microsoft.AspNetCore.App
Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
37
Microsoft.AspNetCore.Mvc.NewtonsoftJson
ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/0a715692d8e2536c899faa0bb4f0cec2c2e33e36
40
Microsoft.AspNetCore.Mvc.NewtonsoftJson
ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/1dcf7acfacf0fe154adcc23270cb0da11ff44ace
44
Microsoft.AspNetCore.Mvc.NewtonsoftJson
ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/31d685b2d9a86ca1243014d175a3da813f78e428
41
Microsoft.AspNetCore.Mvc.NewtonsoftJson
ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/3eeb12e106b9e913c3a4dec1a7d16da7b74149eb
9,529
Microsoft.AspNetCore.Mvc.NewtonsoftJson
ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/3f1acb59718cadf111a0a796681e3d3509bb3381
480
Microsoft.AspNetCore.Mvc.NewtonsoftJson
ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/47576478939fdd59b4400ad135f47938af486ab3
58
Microsoft.AspNetCore.Mvc.NewtonsoftJson
ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/6a6d775f49623bbd742c02f89d373630668547bb
37
Microsoft.AspNetCore.Mvc.NewtonsoftJson
ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/bb01bbf4433e27289b99001b7de6a582879d1835
42
Microsoft.AspNetCore.Mvc.NewtonsoftJson
ASP.NET Core MVC features that use Newtonsoft.Json. Includes input and output formatters for JSON and JSON PATCH. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/fb4b5a21ebd67b31fff4ddf5c039181da504c932
50

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

Version Downloads Last updated
10.0.0 10 11/13/2025
10.0.0-rc.2.25502.107 11 10/18/2025
10.0.0-rc.1.25451.107 14 09/14/2025
10.0.0-preview.7.25380.108 14 08/15/2025
10.0.0-preview.6.25358.103 11 07/18/2025
10.0.0-preview.5.25277.114 11 06/08/2025
10.0.0-preview.4.25258.110 17 05/18/2025
10.0.0-preview.3.25172.1 18 04/17/2025
10.0.0-preview.2.25164.1 20 03/30/2025
10.0.0-preview.1.25120.3 22 02/27/2025
9.0.11 6 11/13/2025
9.0.10 9 10/18/2025
9.0.9 12 09/13/2025
9.0.8 9 08/10/2025
9.0.7 11 07/11/2025
9.0.6 16 06/12/2025
9.0.5 18 05/18/2025
9.0.4 23 04/19/2025
9.0.3 24 03/17/2025
9.0.2 24 02/27/2025
9.0.1 26 01/21/2025
9.0.0 30 11/14/2024
9.0.0-rc.2.24474.3 21 11/15/2024
9.0.0-rc.1.24452.1 23 11/14/2024
9.0.0-preview.7.24406.2 23 12/01/2024
9.0.0-preview.6.24328.4 25 12/11/2024
9.0.0-preview.5.24306.11 27 11/16/2024
9.0.0-preview.4.24267.6 26 05/26/2024
9.0.0-preview.3.24172.13 26 05/26/2024
9.0.0-preview.2.24128.4 27 05/26/2024
9.0.0-preview.1.24081.5 23 05/26/2024
8.0.22 7 11/13/2025
8.0.21 6 10/18/2025
8.0.20 10 09/13/2025
8.0.19 8 08/10/2025
8.0.18 9 07/12/2025
8.0.17 11 06/12/2025
8.0.16 22 05/16/2025
8.0.15 20 04/19/2025
8.0.14 23 03/17/2025
8.0.13 24 02/18/2025
8.0.12 27 01/24/2025
8.0.11 40 11/14/2024
8.0.10 26 11/16/2024
8.0.8 27 11/17/2024
8.0.7 32 11/16/2024
8.0.6 27 11/16/2024
8.0.5 31 05/26/2024
8.0.4 27 05/26/2024
8.0.3 32 05/26/2024
8.0.2 28 05/26/2024
8.0.1 30 02/04/2024
8.0.0 300 12/18/2023
8.0.0-rc.2.23480.2 24 05/26/2024
8.0.0-rc.1.23421.29 28 05/26/2024
8.0.0-preview.7.23375.9 30 05/26/2024
8.0.0-preview.6.23329.11 53 08/08/2023
8.0.0-preview.5.23302.2 28 05/26/2024
8.0.0-preview.4.23260.4 28 05/26/2024
8.0.0-preview.3.23177.8 24 05/26/2024
8.0.0-preview.2.23153.2 25 05/26/2024
8.0.0-preview.1.23112.2 22 05/26/2024
7.0.20 26 11/16/2024
7.0.19 31 05/26/2024
7.0.18 31 05/26/2024
7.0.17 29 05/26/2024
7.0.16 31 05/26/2024
7.0.15 31 05/01/2024
7.0.14 27 02/04/2024
7.0.13 29 05/26/2024
7.0.12 29 05/26/2024
7.0.11 28 05/26/2024
7.0.10 30 05/26/2024
7.0.9 33 05/26/2024
7.0.8 29 05/26/2024
7.0.7 32 05/26/2024
7.0.5 29 06/16/2023
7.0.4 27 05/26/2024
7.0.3 34 07/13/2023
7.0.2 29 05/26/2024
7.0.1 32 05/26/2024
7.0.0 34 05/26/2024
7.0.0-rc.2.22476.2 30 05/26/2024
7.0.0-rc.1.22427.2 24 05/26/2024
7.0.0-preview.7.22376.6 31 05/26/2024
7.0.0-preview.6.22330.3 27 05/26/2024
7.0.0-preview.5.22303.8 24 05/26/2024
7.0.0-preview.4.22251.1 27 05/26/2024
7.0.0-preview.2.22153.2 28 05/26/2024
6.0.36 28 11/19/2024
6.0.35 25 11/17/2024
6.0.33 24 11/17/2024
6.0.32 26 11/17/2024
6.0.31 26 11/17/2024
6.0.30 34 05/26/2024
6.0.29 33 05/26/2024
6.0.28 27 05/26/2024
6.0.27 25 05/26/2024
6.0.26 32 05/26/2024
6.0.25 30 05/26/2024
6.0.24 36 05/26/2024
6.0.23 30 05/26/2024
6.0.22 31 05/26/2024
6.0.21 29 05/26/2024
6.0.20 28 05/26/2024
6.0.19 29 05/26/2024
6.0.18 29 05/26/2024
6.0.16 30 05/26/2024
6.0.15 30 05/26/2024
6.0.14 30 05/26/2024
6.0.13 31 05/26/2024
6.0.12 26 05/26/2024
6.0.11 31 05/26/2024
6.0.10 33 05/26/2024
6.0.9 31 05/03/2024
6.0.7 31 05/26/2024
6.0.6 27 05/26/2024
6.0.5 32 10/28/2022
6.0.0-rc.2.21480.10 26 05/26/2024
6.0.0-rc.1.21452.15 27 11/03/2022
6.0.0-preview.7.21378.6 25 05/26/2024
6.0.0-preview.4.21253.5 27 05/26/2024
6.0.0-preview.3.21201.13 29 05/26/2024
6.0.0-preview.2.21154.6 34 05/26/2024
6.0.0-preview.1.21103.6 27 05/26/2024
5.0.17 32 07/13/2023
5.0.9 34 05/26/2024
5.0.8 33 05/26/2024
5.0.6 31 05/26/2024
5.0.5 27 05/26/2024
5.0.3 35 05/26/2024
5.0.2 38 05/26/2024
5.0.0 32 05/26/2024
5.0.0-rc.1.20451.17 33 05/26/2024
5.0.0-preview.8.20414.8 24 05/26/2024
5.0.0-preview.7.20365.19 32 05/26/2024
5.0.0-preview.6.20312.15 29 05/26/2024
5.0.0-preview.4.20257.10 29 05/26/2024
5.0.0-preview.3.20215.14 25 05/26/2024
3.1.32 9,275 05/11/2023
3.1.31 26 05/26/2024
3.1.29 24 05/26/2024
3.1.28 34 05/26/2024
3.1.27 31 05/26/2024
3.1.26 29 05/26/2024
3.1.25 27 05/26/2024
3.1.23 27 04/30/2024
3.1.19 31 05/26/2024
3.1.18 26 05/26/2024
3.1.8 30 05/26/2024
3.1.6 28 05/26/2024
3.1.1 28 05/26/2024
3.1.0-preview2.19528.8 30 05/26/2024
3.0.0-rc1.19457.4 26 05/26/2024
3.0.0-preview9.19424.4 27 05/26/2024
3.0.0-preview8.19405.7 29 05/26/2024
3.0.0-preview6.19307.2 31 05/26/2024
3.0.0-preview5-19227-01 27 05/26/2024
3.0.0-preview4-19216-03 28 05/26/2024
3.0.0-preview3-19153-02 29 05/26/2024
3.0.0-preview-19075-0444 27 05/26/2024
3.0.0-preview-18579-0056 30 05/26/2024
2.3.0 28 01/20/2025
2.2.0 48 09/08/2023
2.2.0-preview3-35497 29 05/26/2024
2.2.0-preview1-35029 29 05/26/2024
2.1.0 29 05/26/2024
2.1.0-preview1-final 28 05/26/2024
2.0.0 32 06/06/2023
2.0.0-preview2-final 30 05/26/2024
2.0.0-preview1-final 32 05/26/2024
1.1.2 31 05/26/2024
1.1.0-preview1-final 26 05/26/2024
1.0.0-rc2-final 31 05/26/2024