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.
34
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
35
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
36
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
37
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
38
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.
35
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.
36
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.
37
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.
36
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/06b2bc111203f9b9ff0914a7715675a9a66bdac9
34
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
35
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
36
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
34
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,502
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
464
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
55
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
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/fb4b5a21ebd67b31fff4ddf5c039181da504c932
46

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

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