Connection String Builder

Generate database connection strings from form inputs. Supports PostgreSQL, MySQL, MongoDB, Redis, SQLite, and MSSQL with URI, key-value, and .env formats.

About This Tool

The Connection String Builder is a free, browser-based tool that generates database connection strings from a simple form interface. Instead of manually looking up connection string formats for each database engine, you can fill in your host, port, database name, credentials, and options — and instantly get a properly formatted connection string in multiple output formats.

The tool supports six popular database systems: PostgreSQL, MySQL, MongoDB, Redis, SQLite, and Microsoft SQL Server (MSSQL). Each database type comes with sensible defaults for port numbers and usernames, so you only need to change what differs from the standard configuration. Database-specific options are shown contextually — for example, authSource for MongoDB, schema for PostgreSQL, and SRV record toggle for MongoDB Atlas deployments.

Connection strings are generated in three formats simultaneously. The URI string format produces a standard connection URL like postgresql://user:pass@host:5432/db that works with most ORMs and database drivers. The key-value format outputs individual parameters suitable for configuration files. The .env format generates ready-to-paste environment variable declarations, including both the combined DATABASE_URL and individual variables for each connection parameter.

A password visibility toggle lets you hide or reveal credentials in the output. Special characters in usernames and passwords are automatically percent-encoded to produce valid URIs. If you work with SQL databases frequently, you might also find the SQL to Prisma converter or JSON to SQL converter useful alongside this tool.

All processing runs entirely in your browser using JavaScript. Your database credentials, hostnames, and other connection details are never transmitted to any server. There is no logging, no analytics on your input, and no third-party service involvement. This makes it safe to use with production connection parameters.

How to Use

  1. Select your database type (PostgreSQL, MySQL, MongoDB, Redis, SQLite, or MSSQL) from the buttons at the top.
  2. Fill in the Host and Port fields. Default values are pre-filled based on the selected database.
  3. Enter your Database name (or file path for SQLite).
  4. Provide your Username and Password if authentication is required.
  5. Toggle SSL / TLS if your database requires encrypted connections. For MongoDB Atlas, toggle SRV (Atlas) as well.
  6. Fill in optional fields like Schema (PostgreSQL, MSSQL) or Auth Source (MongoDB) as needed.
  7. Switch between URI String, Key-Value, and .env output tabs to get the format you need. Click Copy or press Ctrl+Shift+C to copy.

Popular Connection String Examples

View all connection string examples →

FAQ

Which databases are supported?

The tool supports PostgreSQL, MySQL, MongoDB, Redis, SQLite, and Microsoft SQL Server (MSSQL). Each database type has its own default port, username, and database-specific options like SSL, SRV records, auth source, and schema.

What output formats are available?

Three formats are generated simultaneously: URI string (e.g., postgresql://user:pass@host:5432/db), key-value pairs for configuration files, and .env format with both DATABASE_URL and individual environment variables.

Are special characters in passwords handled correctly?

Yes. Usernames and passwords are automatically percent-encoded (URL-encoded) when generating URI strings. Characters like @, :, /, and others that have special meaning in URIs are properly escaped so the connection string remains valid.

What is the SRV toggle for MongoDB?

The SRV toggle switches the protocol from mongodb:// to mongodb+srv://, which is the format used by MongoDB Atlas and other hosted MongoDB services. SRV connections use DNS service records to discover the cluster topology, so no port number is needed.

Is my data safe?

Yes. All processing runs entirely in your browser using JavaScript. Your database credentials, hostnames, and connection details are never sent to any server. You can verify this by opening your browser's developer tools and monitoring the Network tab while using the tool.

Can I use the generated string with Prisma or Sequelize?

Yes. The URI string format is compatible with most ORMs including Prisma (DATABASE_URL), Sequelize, TypeORM, Knex, and others. The .env tab generates a ready-to-paste DATABASE_URL environment variable. For Prisma specifically, use the URI string directly in your .env file.

How do I connect to a Docker database container?

Use 'localhost' as the host with the port you mapped in your docker-compose.yml or docker run command. For example, if you mapped port 5432:5432 for PostgreSQL, use host=localhost and port=5432. For container-to-container connections within Docker networks, use the container name as the host.

Related Tools