.NET Code Tips

Free .NET developer tool

Connection String Builder & Parser

Build connection strings for SQL Server and Azure SQL, PostgreSQL, SQLite and Azure Storage — or paste one to pull it apart. Copy it raw, as appsettings.json, or as C#.

Runs entirely in your browser — nothing you paste is uploaded.

For Microsoft.Data.SqlClient (also EF Core UseSqlServer).

Your connection string

Connection string
Server=tcp:contoso-sql.database.windows.net,1433;Database=Orders;Authentication=Active Directory Default;Connect Timeout=30;

Parse an existing connection string

Paste any connection string — the provider is detected from its keywords, synonyms like Data Source/Server are understood, and quoted values are handled.

Using connection strings in .NET

Read connection strings from configuration rather than hard-coding them, and when you need to change a value in code, go through the provider's ConnectionStringBuilder instead of concatenating strings — it quotes values correctly and rejects unknown keywords.

Program.cs
// appsettings.json holds the shape; secrets come from user secrets / env vars / Key Vault.
var cs = builder.Configuration.GetConnectionString("DefaultConnection");

// EF Core
builder.Services.AddDbContext<AppDbContext>(o => o.UseSqlServer(cs));

// ADO.NET — build safely instead of concatenating strings
var csb = new SqlConnectionStringBuilder(cs) { ApplicationName = "OrdersApi" };
await using var conn = new SqlConnection(csb.ConnectionString);
await conn.OpenAsync();

Keeping passwords out of appsettings.json

Terminal
dotnet user-secrets init
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=.;Database=Orders;User ID=app;Password=..."

# Production (App Service / containers): double underscore = section separator
ConnectionStrings__DefaultConnection="Server=...;Authentication=Active Directory Default"

Frequently asked questions

Why do I get "The certificate chain was issued by an authority that is not trusted"?

Microsoft.Data.SqlClient 4.0 changed the default to Encrypt=True, so the client now validates the server’s TLS certificate, and a local SQL Server with a self-signed certificate fails that check. Install a trusted certificate on the server, or for local development only add TrustServerCertificate=True. Setting Encrypt=False also works but sends traffic unencrypted.

How do I connect to Azure SQL without a password?

Use Microsoft Entra authentication. With Microsoft.Data.SqlClient 5 or later, set Authentication=Active Directory Default: it uses DefaultAzureCredential, which picks up your Visual Studio or Azure CLI login during development and the app’s managed identity in Azure. Create a contained database user for that identity with CREATE USER [app-name] FROM EXTERNAL PROVIDER.

What is the difference between Server, Data Source and Address?

Nothing: they are synonyms that SqlConnectionStringBuilder normalizes to Data Source, just as Database and Initial Catalog are the same keyword, and User ID, UID and User are the same. Keywords are case-insensitive and order doesn’t matter. This tool accepts any of the synonyms when parsing.

Where should I store connection strings in ASP.NET Core?

Keep the shape in appsettings.json under "ConnectionStrings" without secrets, put development passwords in user secrets (dotnet user-secrets set "ConnectionStrings:DefaultConnection" "..."), and in production supply them through environment variables (ConnectionStrings__DefaultConnection), Azure App Service connection strings, or Key Vault — or avoid passwords entirely with managed identity.