Microsoft.AspNetCore.JsonPatch 10.0.4

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.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
1
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET. This package was built from the source code at https://github.com/aspnet/Mvc/tree/a6199bbfbab05583f987bae322fb04566841aaea
1
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
4 327
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/379bfc7b2559e7cc9f42f997a497b2f2dd8e12d2
1
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
301
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
498
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/4e7d976438b0fc17f435804e801d5d68d193ec33
6 196
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/8899cb30120d41413065f1b1465cdabefe0a1f9c
917
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/954f61dd38b33caa2b736c73530bd5a294174437
70
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/c2a442982e736e17ae6bcadbfd8ccba278ee1be6
322
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/ee417479933278bb5aadc5944706a96b5ef74a5d
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/ef18546e04f9b0127bbd7709b6af054cc18da98a
30
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/fa4d80b76c2431a825be026f6bbabca63e1f42ef
18
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/dotnet/tree/80d3e14f5e08b4888f464e3cd0d0b2445b63ec46
10

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

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