Soenneker.JavaScript.Formatter 11.0.211

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.JavaScript.Formatter --version 11.0.211
                    
NuGet\Install-Package Soenneker.JavaScript.Formatter -Version 11.0.211
                    
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.JavaScript.Formatter" Version="11.0.211" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.JavaScript.Formatter" Version="11.0.211" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.JavaScript.Formatter" />
                    
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.JavaScript.Formatter --version 11.0.211
                    
#r "nuget: Soenneker.JavaScript.Formatter, 11.0.211"
                    
#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.JavaScript.Formatter@11.0.211
                    
#: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.JavaScript.Formatter&version=11.0.211
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.JavaScript.Formatter&version=11.0.211
                    
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 alternate text is missing from this package README image

Soenneker.JavaScript.Formatter

Parses and serializes JavaScript as readable or compact source, with helpers for files and directories.

Install

dotnet add package Soenneker.JavaScript.Formatter

Register

using Soenneker.JavaScript.Formatter.Registrars;

services.AddJavaScriptFormatterAsSingleton();

A scoped registration is available through AddJavaScriptFormatterAsScoped().

Format source

using Soenneker.JavaScript.Formatter.Abstract;

string readable = await formatter.PrettyPrint(
    "function total(a,b){return a+b}",
    cancellationToken);

string compact = await formatter.Normalize(readable, cancellationToken);

PrettyPrint() uses four-space indentation and K&R-style braces. Normalize() emits compact source; it is a canonical serializer, not an optimizing minifier.

Both methods parse into an AST and generate new source. They are not lossless: comments, original whitespace, quote choices, and semicolon choices may not be preserved. Do not use these APIs when license comments, source-map comments, or exact source text must survive.

The parser accepts JavaScript scripts and modules and retries the alternate source type when needed. Invalid JavaScript and unsupported syntax such as TypeScript annotations cause an Acornima.ParseErrorException. Null, empty, or whitespace-only input produces an empty string.

Format files

string preview = await formatter.PrettyPrintFile(
    "src/app.js",
    cancellationToken: cancellationToken);

await formatter.SavePrettyPrintedFile(
    sourcePath: "src/app.js",
    destinationPath: "output/app.js",
    cancellationToken: cancellationToken);

await formatter.SaveNormalizedFile(
    sourcePath: "src/app.js",
    cancellationToken: cancellationToken); // overwrites src/app.js

The read methods return transformed source without modifying the file. The Save methods write to the destination, or overwrite the source when no destination is supplied.

Format a directory

await formatter.PrettyPrintDirectory(
    "src",
    recursive: true,
    cancellationToken: cancellationToken);

This overwrites .js, .mjs, and .cjs files in place. Cancellation does not restore files already written. The token is observed before parsing and throughout file operations, but the synchronous parser itself cannot be interrupted after it starts processing one source string.

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.213 48 12/3/2026
11.0.212 59 12/3/2026
11.0.211 50 12/3/2026
11.0.210 49 12/3/2026
11.0.209 50 12/3/2026
11.0.208 50 12/2/2026
11.0.207 51 12/2/2026
11.0.204 50 12/2/2026
11.0.202 74 12/2/2026
11.0.201 70 12/2/2026
11.0.200 68 12/2/2026
11.0.199 88 12/2/2026
11.0.198 83 12/1/2026
11.0.197 85 12/1/2026
11.0.196 84 12/1/2026
11.0.195 79 12/1/2026
11.0.194 78 12/1/2026
11.0.193 91 12/1/2026
11.0.192 85 12/1/2026
11.0.191 94 11/30/2026
Loading failed

Updated Multiple NuGet packages