Microsoft.AspNetCore.JsonPatch 10.0.0-rc.2.25502.107

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. This package was built from the source code at https://github.com/aspnet/Mvc/tree/a6199bbfbab05583f987bae322fb04566841aaea
120
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
109
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
108
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
107
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
106
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
105
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
104
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 at: https://github.com/aspnet/Mvc/tree/b9793f0a1d9a75940c50e31e956d09397a5d1876
101
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
100
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 at: https://github.com/aspnet/Mvc/tree/522006d2c866add522a546aa3b4720577f1cee57
100
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
99
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
98
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
97
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
94
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
92
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
90

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

Version Downloads Last updated
10.0.0-rc.2.25502.107 3 10/14/2025
10.0.0-rc.1.25451.107 17 9/10/2025
10.0.0-preview.7.25380.108 21 8/13/2025
10.0.0-preview.6.25358.103 17 7/16/2025
10.0.0-preview.5.25277.114 32 6/8/2025
10.0.0-preview.4.25258.110 26 5/14/2025
10.0.0-preview.3.25172.1 33 4/14/2025
10.0.0-preview.2.25164.1 47 3/22/2025
10.0.0-preview.1.25120.3 46 2/27/2025
9.0.10 2 10/15/2025
9.0.9 14 9/10/2025
9.0.8 18 8/5/2025
9.0.7 18 7/11/2025
9.0.6 24 6/14/2025
9.0.5 27 5/14/2025
9.0.4 36 4/11/2025
9.0.3 39 3/15/2025
9.0.2 36 2/14/2025
9.0.1 50 1/19/2025
9.0.0 51 11/13/2024
9.0.0-rc.2.24474.3 43 10/8/2024
9.0.0-rc.1.24452.1 50 9/12/2024
9.0.0-preview.7.24406.2 61 8/13/2024
9.0.0-preview.6.24328.4 57 7/10/2024
9.0.0-preview.5.24306.11 53 6/15/2024
9.0.0-preview.4.24267.6 51 5/24/2024
9.0.0-preview.3.24172.13 58 4/16/2024
9.0.0-preview.2.24128.4 54 3/14/2024
9.0.0-preview.1.24081.5 59 2/20/2024
8.0.21 3 10/15/2025
8.0.20 21 9/10/2025
8.0.19 19 8/5/2025
8.0.18 20 7/11/2025
8.0.17 23 6/14/2025
8.0.16 32 5/14/2025
8.0.15 28 4/11/2025
8.0.14 34 3/15/2025
8.0.13 35 2/14/2025
8.0.12 44 1/19/2025
8.0.11 48 11/13/2024
8.0.10 44 10/8/2024
8.0.8 56 8/13/2024
8.0.7 69 7/9/2024
8.0.6 55 5/29/2024
8.0.5 55 5/17/2024
8.0.4 52 4/14/2024
8.0.3 53 3/12/2024
8.0.2 56 2/19/2024
8.0.1 64 2/3/2024
8.0.0 54 11/15/2023
8.0.0-rc.2.23480.2 78 10/12/2023
8.0.0-rc.1.23421.29 73 9/15/2023
8.0.0-preview.7.23375.9 69 8/22/2023
8.0.0-preview.6.23329.11 71 7/30/2023
8.0.0-preview.5.23302.2 78 7/26/2023
8.0.0-preview.4.23260.4 85 7/31/2023
8.0.0-preview.3.23177.8 80 5/14/2023
8.0.0-preview.2.23153.2 75 4/11/2023
8.0.0-preview.1.23112.2 76 2/25/2023
7.0.20 59 5/29/2024
7.0.19 53 5/17/2024
7.0.18 53 4/14/2024
7.0.17 60 3/12/2024
7.0.16 60 2/21/2024
7.0.15 61 1/23/2024
7.0.14 70 11/15/2023
7.0.13 67 10/30/2023
7.0.12 63 10/10/2023
7.0.11 62 9/16/2023
7.0.10 66 8/22/2023
7.0.9 64 7/31/2023
7.0.8 65 7/12/2023
7.0.7 69 7/16/2023
7.0.5 68 7/31/2023
7.0.4 61 7/31/2023
7.0.3 69 2/21/2023
7.0.2 80 1/27/2023
7.0.1 67 2/23/2023
7.0.0 78 12/4/2022
7.0.0-rc.2.22476.2 86 11/4/2022
7.0.0-rc.1.22427.2 79 9/25/2022
7.0.0-preview.7.22376.6 80 10/25/2022
7.0.0-preview.6.22330.3 60 11/27/2022
7.0.0-preview.5.22303.8 88 6/27/2022
7.0.0-preview.4.22251.1 79 6/28/2022
7.0.0-preview.3.22178.4 80 3/9/2023
7.0.0-preview.2.22153.2 62 9/17/2022
7.0.0-preview.1.22109.13 82 11/4/2022
6.0.36 60 11/13/2024
6.0.35 48 10/8/2024
6.0.33 55 8/13/2024
6.0.32 58 7/9/2024
6.0.31 56 5/29/2024
6.0.30 63 5/17/2024
6.0.29 54 4/14/2024
6.0.28 56 3/12/2024
6.0.27 68 2/19/2024
6.0.26 54 1/28/2024
6.0.25 63 11/15/2023
6.0.24 73 10/30/2023
6.0.23 82 10/10/2023
6.0.22 74 9/16/2023
6.0.21 65 8/22/2023
6.0.20 88 7/20/2023
6.0.19 74 7/31/2023
6.0.18 64 7/31/2023
6.0.16 68 5/13/2023
6.0.15 64 4/5/2023
6.0.14 84 2/23/2023
6.0.13 65 2/23/2023
6.0.12 74 2/23/2023
6.0.11 66 11/24/2022
6.0.10 69 12/4/2022
6.0.9 60 5/13/2023
6.0.8 71 12/25/2022
6.0.7 82 12/22/2022
6.0.6 89 6/29/2022
6.0.5 64 11/30/2022
6.0.4 84 1/5/2023
6.0.3 70 11/4/2022
6.0.2 70 11/5/2022
6.0.1 70 10/14/2022
6.0.0 101 7/10/2022
6.0.0-rc.2.21480.10 75 1/14/2023
6.0.0-rc.1.21452.15 95 12/24/2022
6.0.0-preview.7.21378.6 76 6/29/2022
6.0.0-preview.6.21355.2 83 2/28/2023
6.0.0-preview.5.21301.17 76 11/7/2022
6.0.0-preview.4.21253.5 78 10/26/2022
6.0.0-preview.3.21201.13 78 6/28/2022
6.0.0-preview.2.21154.6 69 9/21/2022
6.0.0-preview.1.21103.6 73 9/22/2022
5.0.17 73 9/2/2022
5.0.16 63 12/21/2022
5.0.15 87 8/10/2022
5.0.14 65 1/20/2023
5.0.13 61 10/21/2022
5.0.12 67 5/13/2023
5.0.11 81 9/19/2022
5.0.10 61 11/30/2022
5.0.9 74 1/22/2023
5.0.8 66 5/13/2023
5.0.7 77 9/21/2022
5.0.6 68 9/13/2022
5.0.5 85 12/15/2022
5.0.4 75 10/3/2022
5.0.3 84 10/3/2022
5.0.2 80 12/30/2022
5.0.1 73 2/21/2023
5.0.0 87 2/2/2023
5.0.0-rc.2.20475.17 74 10/16/2022
5.0.0-rc.1.20451.17 88 10/22/2022
5.0.0-preview.8.20414.8 77 10/19/2022
5.0.0-preview.7.20365.19 74 2/28/2023
5.0.0-preview.6.20312.15 78 8/18/2022
5.0.0-preview.5.20279.2 68 3/24/2023
5.0.0-preview.4.20257.10 84 10/10/2022
5.0.0-preview.3.20215.14 80 11/24/2022
5.0.0-preview.2.20167.3 83 10/14/2022
5.0.0-preview.1.20124.5 76 4/9/2023
3.1.32 85 2/23/2023
3.1.31 68 12/4/2022
3.1.30 75 12/4/2022
3.1.29 57 5/13/2023
3.1.28 82 9/8/2022
3.1.27 67 11/14/2022
3.1.26 60 5/17/2023
3.1.25 97 8/25/2022
3.1.24 68 6/27/2022
3.1.23 71 10/6/2022
3.1.22 73 11/7/2022
3.1.21 78 6/28/2022
3.1.20 59 5/17/2023
3.1.19 86 9/5/2022
3.1.18 60 2/7/2023
3.1.17 70 8/29/2022
3.1.16 71 9/26/2022
3.1.15 59 12/18/2022
3.1.14 67 9/26/2022
3.1.13 66 9/3/2022
3.1.12 71 6/30/2022
3.1.11 77 2/11/2023
3.1.10 88 10/15/2022
3.1.9 69 6/29/2022
3.1.8 66 9/20/2022
3.1.7 73 5/13/2023
3.1.6 67 8/9/2022
3.1.5 66 12/21/2022
3.1.4 72 6/30/2022
3.1.3 60 9/18/2022
3.1.2 72 9/5/2022
3.1.1 67 12/2/2022
3.1.0 77 9/26/2022
3.1.0-preview3.19555.2 79 3/2/2023
3.1.0-preview2.19528.8 74 9/13/2022
3.1.0-preview1.19508.20 81 3/19/2023
3.0.3 80 6/28/2022
3.0.2 72 5/17/2023
3.0.0 82 9/3/2022
3.0.0-rc1.19457.4 61 9/18/2022
3.0.0-preview9.19424.4 78 11/15/2022
3.0.0-preview8.19405.7 80 9/7/2022
3.0.0-preview7.19365.7 75 9/10/2022
3.0.0-preview6.19307.2 70 10/7/2022
3.0.0-preview5-19227-01 81 9/9/2022
3.0.0-preview4-19216-03 65 8/25/2022
3.0.0-preview3-19153-02 90 6/30/2022
3.0.0-preview-19075-0444 75 10/10/2022
3.0.0-preview-18579-0056 85 10/27/2022
2.3.0 44 1/19/2025
2.2.0 76 9/16/2022
2.2.0-preview3-35497 81 9/8/2022
2.2.0-preview2-35157 61 1/25/2023
2.2.0-preview1-35029 82 10/4/2022
2.1.1 61 5/16/2023
2.1.0 71 11/14/2022
2.1.0-rc1-final 62 9/27/2022
2.1.0-preview2-final 71 10/8/2022
2.1.0-preview1-final 68 9/21/2022
2.0.0 84 10/1/2022
2.0.0-preview2-final 84 9/30/2022
2.0.0-preview1-final 89 10/17/2022
1.1.2 80 12/15/2022
1.1.1 102 6/30/2022
1.1.0 67 9/28/2022
1.1.0-preview1-final 77 1/27/2023
1.0.0 81 10/3/2022
1.0.0-rc2-final 78 10/4/2022