Soenneker.Css.Minify 11.0.203

Prefix Reserved
dotnet add package Soenneker.Css.Minify --version 11.0.203
                    
NuGet\Install-Package Soenneker.Css.Minify -Version 11.0.203
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Css.Minify" Version="11.0.203" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Css.Minify" Version="11.0.203" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Css.Minify" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Css.Minify --version 11.0.203
                    
#r "nuget: Soenneker.Css.Minify, 11.0.203"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Css.Minify@11.0.203
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Css.Minify&version=11.0.203
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Css.Minify&version=11.0.203
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Css.Minify

A CSS text and file minifier powered by Soenneker.Esbuild.Util.

Installation

dotnet add package Soenneker.Css.Minify

Registration

using Soenneker.Css.Minify.Abstract;
using Soenneker.Css.Minify.Registrars;

services.AddCssMinifierAsSingleton();

ICssMinifier minifier = serviceProvider.GetRequiredService<ICssMinifier>();

AddCssMinifierAsScoped() is also available. Both methods register matching lifetimes for IEsbuildUtil and IFileUtil.

Minify CSS text

const string css = """
    /* navigation */
    .nav .item001 {
        margin: 0px  0.50rem;
        color: #001122;
        width: calc(100% - 1rem);
    }
    """;

string result = await minifier.Minify(css, cancellationToken);
// Returns the CSS minified by esbuild.

Text minification is asynchronous and accepts a cancellation token. Null, empty, and whitespace input returns an empty string. Span callers should convert their input to a string before calling.

Nonempty input uses esbuild's CSS loader with minification enabled, without bundling or resolving imports. Output follows esbuild defaults, including legal-comment preservation and a trailing newline. Browser targets are not configured, so output assumes modern CSS support.

Minify a file

await minifier.MinifyFile(
    inputPath: "wwwroot/css/site.css",
    outputPath: "wwwroot/css/site.min.css",
    cancellationToken);

The input file is read completely, minified in memory, and written to the output path through IFileUtil. Existing output is replaced according to that utility's write behavior. File errors and cancellation propagate to the caller.

Scope and validation

The esbuild utility manages its Node/npm installation and checks npm for the latest esbuild release on each operation. Nonempty minification therefore requires network access, a writable installation directory, and permission to launch processes. This is intended for asset/build pipelines; cache generated output rather than minifying on every web request.

Esbuild failures and cancellation propagate to the caller. Minification can rewrite CSS syntax and colors, and output may change as esbuild updates.

Minification is not sanitization. Do not treat arbitrary CSS as safe merely because it passed through this library.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.203 0 11/15/2026
11.0.202 84 11/12/2026
11.0.201 77 11/11/2026
11.0.200 63 11/11/2026
11.0.199 85 11/11/2026
11.0.197 79 11/11/2026
11.0.196 77 11/11/2026
11.0.195 66 11/11/2026
11.0.194 116 11/10/2026
11.0.193 169 11/3/2026
11.0.192 100 11/3/2026
11.0.191 105 11/3/2026
11.0.190 89 11/3/2026
11.0.189 97 11/3/2026
11.0.188 101 11/3/2026
11.0.187 105 11/3/2026
11.0.186 111 11/3/2026
11.0.185 96 11/2/2026
11.0.184 109 11/2/2026
11.0.183 98 11/2/2026
Loading failed

Update dependency Soenneker.Esbuild.Util to 11.0.55 (#392)