Laan.Sql.Formatter
0.3.5
.NET 9.0
This package targets .NET 9.0. The package is compatible with this framework or higher.
.NET Framework 4.7.2
This package targets .NET Framework 4.7.2. The package is compatible with this framework or higher.
dotnet add package Laan.Sql.Formatter --version 0.3.5
NuGet\Install-Package Laan.Sql.Formatter -Version 0.3.5
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="Laan.Sql.Formatter" Version="0.3.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Laan.Sql.Formatter" Version="0.3.5" />
<PackageReference Include="Laan.Sql.Formatter" />
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 Laan.Sql.Formatter --version 0.3.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Laan.Sql.Formatter, 0.3.5"
#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 Laan.Sql.Formatter@0.3.5
#: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=Laan.Sql.Formatter&version=0.3.5
#tool nuget:?package=Laan.Sql.Formatter&version=0.3.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Laan.Sql.Formatter
A T-SQL formatter for .NET. Turns messy or machine-generated SQL into clean, consistently styled code.
Quick Start
using Laan.Sql.Formatter;
// Default options
var engine = new FormattingEngine();
string result = engine.Execute("select id,name from users where active=1");
Output:
SELECT id,
name
FROM users
WHERE active = 1
Custom Options
var options = new FormattingOptions
{
IndentSize = 2,
UseSpaces = true,
MaxLineLength = 120,
KeywordCasing = KeywordCasing.Lower,
BracketSpacing = BracketSpacing.NoSpaces,
BlankLinesBetweenClauses = 1,
MaxInlineSelectColumns = 3,
MaxInlineInsertColumns = 4,
};
var engine = new FormattingEngine(options);
Config File
Drop a .sqlformat.json in your project (or any parent directory) and it will be picked up automatically:
{
"indentSize": 4,
"useSpaces": true,
"maxLineLength": 80,
"keywordCasing": "Upper",
"bracketSpacing": "NoSpaces",
"blankLinesBetweenClauses": 1,
"maxInlineSelectColumns": 1,
"maxInlineInsertColumns": 4
}
// Auto-discover from current directory up to root
var options = FormattingOptionsLoader.TryLoadFromHierarchy();
var engine = new FormattingEngine(options);
// Load an explicit file
var engine = FormattingEngine.CreateWithConfigFile("custom.sqlformat.json");
Options Reference
| Option | Type | Default | Description |
|---|---|---|---|
indentSize |
int | 4 | Spaces or tabs per indent level |
useSpaces |
bool | true | Spaces (true) or tabs (false) |
maxLineLength |
int | 80 | Max line length before wrapping |
keywordCasing |
enum | Upper | Upper, Lower, or Pascal |
bracketSpacing |
enum | NoSpaces | NoSpaces → (x) · WithSpaces → ( x ) |
blankLinesBetweenClauses |
int | 1 | Blank lines between major clauses |
maxInlineSelectColumns |
int | 1 | SELECT columns before wrapping |
maxInlineInsertColumns |
int | 4 | INSERT columns before wrapping |
Targets
net472net481net9.0net10.0
Source
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Framework | net472 is compatible. net48 was computed. net481 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.7.2
- Laan.Sql.Parser (>= 0.3.5)
- System.Text.Json (>= 9.0.1)
-
.NETFramework 4.8.1
- Laan.Sql.Parser (>= 0.3.5)
- System.Text.Json (>= 9.0.1)
-
net10.0
- Laan.Sql.Parser (>= 0.3.5)
-
net9.0
- Laan.Sql.Parser (>= 0.3.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Laan.Sql.Formatter:
| Package | Downloads |
|---|---|
|
Laan.NHibernate.Appender
SQL Formatter for NHibernate via the Log4net Appender infrastructure |
GitHub repositories
This package is not used by any popular GitHub repositories.