Microsoft.AspNetCore.JsonPatch 10.0.0-preview.6.25358.103

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.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.
81
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/aee5e4080331553ea9dfb7fb388b6d72f715bf6a
74
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
63
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.
63
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.
61
Microsoft.AspNetCore.App
Microsoft.AspNetCore.App
60
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
59
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.
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.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. This package was built from the source at: https://github.com/aspnet/Universe/tree/244e037a222a7cd0a17feafb7f3a625fde40de97
46
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
46
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/c663adee8e64ba5d379fa0edfb8201984a7df7d0
45
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/f6cb1b5953598e1562d33e1cbbdae2b130792833
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/e5f183b656a0e8bc087108130a5a9b54ae94494e
43
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/02c6de4ba6022025fcda7581415f310f8c73cdc3
40
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.
40
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.
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.
36
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.
34

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

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