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.
49
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
50
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
51
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
52
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
54
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
56
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.
54
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.
51
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
56
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
56
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,614
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
525
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
73
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
51
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
60

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

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