Microsoft.AspNetCore.JsonPatch 10.0.1

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
153
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
147
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
139
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
138
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
137
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
135
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
133
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
133
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
132
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
131
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
129
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
127
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
126
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
125
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/fb57810f2960730e59db0235207b873c924bc3fd
124
Microsoft.AspNetCore.Mvc.Formatters.Json
ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.
123

.NET Framework 4.6.2

.NET 10.0

.NET Standard 2.0

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