Microsoft.AspNetCore.JsonPatch 10.0.6

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
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/277e317dd5cab9859ceea4c8ebae218522c2c173
89
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/718171eeb4bd236ab4f0d9b1ecd97ecc63ec0be1
23
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/432e6a061f28dda696ba16bc5442328d23b25d93
20
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/617d594f2bf75a8904d3d0e7d68a0bacf8e6763a
14
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/dc5e11abdb05b322f4b74b3afbcfb352fe984b2e
13
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/aspnet/AspNetCore/tree/844a82e37cae48af2ab2ee4f39b41283e6bb4f0e
13
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/aspnet/AspNetCore/tree/c75b3f7a2fb9fe21fd96c93c070fdfa88a2fbe97
12
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/aspnet/AspNetCore/tree/cf2c5c9c6dca430b97aa96429b84d0da07eb77f1
12
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/aspnet/AspNetCore/tree/331b52b370cd4e7fe2919d4d4cda27412e2ab1cc
12
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/aspnet/AspNetCore/tree/4d0b3722384bfec7d4c210674df9b7bf1e59da90
12
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/3b519aa7d1a1b66e1d329d694f814e1d8228dc8c
12
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/c49ccc8727c620ce1cb8fb431bb3fe8f2e747236
12
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
12
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/aspnet/AspNetCore/tree/561deb05ae2d6680206e3d4a6bc75de699585980
11
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/3c37ef8f5358abb303c05d299f029fca7d867d56
11
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/371a26f07b23ad77c636332c2dfc0cbd1d8137ba
11
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/898c164a1f537a8210a26eaf388bdc92531f6b09
11
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/aspnet/AspNetCore/tree/1bf292d47ac2a0ebda07d8a3f00355dd01915ad5
10
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/febee99db845fd8766a13bdb391a07c3ee90b4ba
10

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

Version Downloads Last updated
11.0.0-preview.4.26230.115 0 05/12/2026
11.0.0-preview.3.26207.106 2 04/15/2026
11.0.0-preview.2.26159.112 5 03/12/2026
11.0.0-preview.1.26104.118 6 02/17/2026
10.0.8 0 05/12/2026
10.0.7 0 04/21/2026
10.0.6 2 04/16/2026
10.0.5 5 03/14/2026
10.0.4 4 03/12/2026
10.0.3 5 02/16/2026
10.0.2 3 01/20/2026
10.0.1 1 12/10/2025
10.0.0 1 12/10/2025
10.0.0-rc.2.25502.107 1 01/04/2026
10.0.0-rc.1.25451.107 1 12/10/2025
10.0.0-preview.7.25380.108 3 03/09/2026
10.0.0-preview.6.25358.103 1 01/25/2026
10.0.0-preview.5.25277.114 1 12/11/2025
10.0.0-preview.4.25258.110 3 02/03/2026
10.0.0-preview.3.25172.1 2 01/21/2026
10.0.0-preview.2.25164.1 5 02/11/2026
10.0.0-preview.1.25120.3 1 01/29/2026
9.0.16 0 05/12/2026
9.0.15 2 04/16/2026
9.0.14 5 03/12/2026
9.0.13 6 02/18/2026
9.0.12 4 01/28/2026
9.0.11 6 12/10/2025
9.0.10 3 12/10/2025
9.0.9 3 03/08/2026
9.0.8 6 12/11/2025
9.0.7 5 12/30/2025
9.0.6 6 12/11/2025
9.0.5 5 12/30/2025
9.0.4 7 12/30/2025
9.0.3 7 12/11/2025
9.0.2 6 12/11/2025
9.0.1 5 12/30/2025
9.0.0 4 02/09/2026
9.0.0-rc.2.24474.3 4 12/10/2025
9.0.0-rc.1.24452.1 10 12/10/2025
9.0.0-preview.7.24406.2 6 12/10/2025
9.0.0-preview.6.24328.4 5 12/10/2025
9.0.0-preview.5.24306.11 4 12/10/2025
9.0.0-preview.4.24267.6 3 12/10/2025
9.0.0-preview.3.24172.13 6 12/10/2025
9.0.0-preview.2.24128.4 6 12/10/2025
9.0.0-preview.1.24081.5 3 12/10/2025
8.0.27 2 05/29/2026
8.0.26 3 04/22/2026
8.0.25 5 03/13/2026
8.0.24 7 02/18/2026
8.0.23 6 01/28/2026
8.0.22 6 12/10/2025
8.0.21 5 12/10/2025
8.0.20 3 12/10/2025
8.0.19 4 12/10/2025
8.0.18 4 12/10/2025
8.0.17 5 12/10/2025
8.0.16 5 12/10/2025
8.0.15 4 12/10/2025
8.0.14 5 12/10/2025
8.0.13 4 12/10/2025
8.0.12 3 12/10/2025
8.0.11 4 12/10/2025
8.0.10 7 12/10/2025
8.0.8 5 02/03/2026
8.0.7 4 12/30/2025
8.0.6 4 12/30/2025
8.0.5 5 12/30/2025
8.0.4 4 12/30/2025
8.0.3 4 12/11/2025
8.0.2 5 12/30/2025
8.0.1 6 12/30/2025
8.0.0 5 02/03/2026
8.0.0-rc.2.23480.2 4 12/10/2025
8.0.0-rc.1.23421.29 4 12/10/2025
8.0.0-preview.7.23375.9 5 12/10/2025
8.0.0-preview.6.23329.11 7 12/10/2025
8.0.0-preview.5.23302.2 3 12/10/2025
8.0.0-preview.4.23260.4 4 12/10/2025
8.0.0-preview.3.23177.8 3 12/10/2025
8.0.0-preview.2.23153.2 6 12/10/2025
8.0.0-preview.1.23112.2 4 12/10/2025
7.0.20 4 12/10/2025
7.0.19 4 12/10/2025
7.0.18 6 12/10/2025
7.0.17 6 12/10/2025
7.0.16 6 12/10/2025
7.0.15 5 12/10/2025
7.0.14 5 12/10/2025
7.0.13 5 12/10/2025
7.0.12 2 12/10/2025
7.0.11 5 12/10/2025
7.0.10 6 12/10/2025
7.0.9 9 12/11/2025
7.0.8 6 12/30/2025
7.0.7 4 02/10/2026
7.0.5 8 12/30/2025
7.0.4 6 12/30/2025
7.0.3 5 12/30/2025
7.0.2 4 12/30/2025
7.0.1 8 12/30/2025
7.0.0 3 03/08/2026
7.0.0-rc.2.22476.2 5 12/10/2025
7.0.0-rc.1.22427.2 3 12/10/2025
7.0.0-preview.7.22376.6 5 12/10/2025
7.0.0-preview.6.22330.3 6 12/10/2025
7.0.0-preview.5.22303.8 4 12/10/2025
7.0.0-preview.4.22251.1 5 12/10/2025
7.0.0-preview.3.22178.4 6 12/10/2025
7.0.0-preview.2.22153.2 4 12/10/2025
7.0.0-preview.1.22109.13 6 12/10/2025
6.0.36 2 12/10/2025
6.0.35 5 12/10/2025
6.0.33 3 12/10/2025
6.0.32 5 12/10/2025
6.0.31 5 01/31/2026
6.0.30 4 12/10/2025
6.0.29 5 12/10/2025
6.0.28 3 12/10/2025
6.0.27 5 12/10/2025
6.0.26 4 12/10/2025
6.0.25 5 12/10/2025
6.0.24 5 12/10/2025
6.0.23 2 12/10/2025
6.0.22 4 12/10/2025
6.0.21 6 12/10/2025
6.0.20 5 12/10/2025
6.0.19 6 12/10/2025
6.0.18 4 12/10/2025
6.0.16 4 12/10/2025
6.0.15 5 12/10/2025
6.0.14 6 12/10/2025
6.0.13 5 12/10/2025
6.0.12 4 12/10/2025
6.0.11 5 12/10/2025
6.0.10 5 12/10/2025
6.0.9 6 12/11/2025
6.0.8 5 12/30/2025
6.0.7 4 12/30/2025
6.0.6 5 02/03/2026
6.0.5 6 12/30/2025
6.0.4 5 12/10/2025
6.0.3 5 12/30/2025
6.0.2 4 12/30/2025
6.0.1 6 12/30/2025
6.0.0 2 03/08/2026
6.0.0-rc.2.21480.10 4 12/10/2025
6.0.0-rc.1.21452.15 5 12/10/2025
6.0.0-preview.7.21378.6 4 12/10/2025
6.0.0-preview.6.21355.2 5 12/10/2025
6.0.0-preview.5.21301.17 7 12/10/2025
6.0.0-preview.4.21253.5 8 12/10/2025
6.0.0-preview.3.21201.13 5 12/10/2025
6.0.0-preview.2.21154.6 5 12/10/2025
6.0.0-preview.1.21103.6 4 12/10/2025
5.0.17 5 12/10/2025
5.0.16 5 12/10/2025
5.0.15 6 12/10/2025
5.0.14 3 12/10/2025
5.0.13 6 12/10/2025
5.0.12 4 12/10/2025
5.0.11 5 12/10/2025
5.0.10 5 12/10/2025
5.0.9 6 12/30/2025
5.0.8 7 12/30/2025
5.0.7 6 12/30/2025
5.0.6 6 12/30/2025
5.0.5 4 02/23/2026
5.0.4 2 12/30/2025
5.0.3 4 12/30/2025
5.0.2 7 12/30/2025
5.0.1 4 12/30/2025
5.0.0 4 02/06/2026
5.0.0-rc.2.20475.17 4 12/10/2025
5.0.0-rc.1.20451.17 6 12/10/2025
5.0.0-preview.8.20414.8 5 12/10/2025
5.0.0-preview.7.20365.19 5 12/10/2025
5.0.0-preview.6.20312.15 2 12/10/2025
5.0.0-preview.5.20279.2 5 12/10/2025
5.0.0-preview.4.20257.10 3 12/10/2025
5.0.0-preview.3.20215.14 5 12/10/2025
5.0.0-preview.2.20167.3 4 12/10/2025
5.0.0-preview.1.20124.5 8 12/10/2025
3.1.32 3 12/10/2025
3.1.31 5 12/10/2025
3.1.30 8 12/10/2025
3.1.29 4 12/10/2025
3.1.28 4 12/10/2025
3.1.27 3 12/10/2025
3.1.26 4 12/10/2025
3.1.25 3 12/10/2025
3.1.24 5 12/10/2025
3.1.23 3 12/10/2025
3.1.22 4 12/10/2025
3.1.21 2 12/10/2025
3.1.20 5 12/10/2025
3.1.19 4 12/10/2025
3.1.18 6 12/10/2025
3.1.17 5 12/10/2025
3.1.16 3 12/10/2025
3.1.15 6 12/10/2025
3.1.14 4 12/10/2025
3.1.13 6 12/10/2025
3.1.12 5 12/10/2025
3.1.11 4 12/10/2025
3.1.10 3 12/10/2025
3.1.9 5 12/30/2025
3.1.8 6 12/30/2025
3.1.7 5 12/30/2025
3.1.6 4 12/30/2025
3.1.5 4 12/30/2025
3.1.4 5 12/30/2025
3.1.3 6 12/26/2025
3.1.2 6 12/30/2025
3.1.1 7 12/26/2025
3.1.0 4 12/30/2025
3.1.0-preview3.19555.2 4 12/10/2025
3.1.0-preview2.19528.8 4 12/10/2025
3.1.0-preview1.19508.20 6 01/28/2026
3.0.3 6 12/26/2025
3.0.2 5 12/30/2025
3.0.0 6 12/10/2025
3.0.0-rc1.19457.4 5 12/11/2025
3.0.0-preview9.19424.4 6 02/04/2026
3.0.0-preview8.19405.7 4 02/02/2026
3.0.0-preview7.19365.7 4 01/21/2026
3.0.0-preview6.19307.2 3 02/02/2026
3.0.0-preview5-19227-01 6 01/29/2026
3.0.0-preview4-19216-03 4 02/05/2026
3.0.0-preview3-19153-02 4 01/29/2026
3.0.0-preview-19075-0444 4 12/11/2025
3.0.0-preview-18579-0056 4 12/11/2025
2.3.10 0 05/12/2026
2.3.9 5 01/28/2026
2.3.8 4 01/29/2026
2.3.0 5 12/30/2025
2.2.0 4 01/26/2026
2.2.0-preview3-35497 4 02/02/2026
2.2.0-preview2-35157 3 02/18/2026
2.2.0-preview1-35029 6 02/02/2026
2.1.1 6 02/02/2026
2.1.0 4 12/30/2025
2.1.0-rc1-final 4 01/04/2026
2.1.0-preview2-final 5 01/29/2026
2.1.0-preview1-final 4 01/29/2026
2.0.0 4 02/03/2026
2.0.0-preview2-final 9 01/21/2026
2.0.0-preview1-final 5 02/02/2026
1.1.2 4 02/06/2026
1.1.1 3 12/26/2025
1.1.0 5 01/22/2026
1.1.0-preview1-final 6 02/02/2026
1.0.0 3 03/09/2026
1.0.0-rc2-final 5 01/04/2026