DevTools Logo

Database Connection String Builder

Database Connection String Builder

Assemble correct, URL-encoded connection strings for the databases you use most — nothing leaves your browser.

Database Engine

Select target database

Connection Details

Configure credentials and host parameters

Examples

Default PostgreSQL — host, user, db, no password

Input
db:       postgresql
host:     localhost
port:     5432
username: admin
password: (empty)
database: mydb
SSL:      off
Output
Connection URI: postgresql://admin@localhost:5432/mydb
JDBC URL:        jdbc:postgresql://localhost:5432/mydb
libpq:           host=localhost port=5432 dbname=mydb user=admin

The host defaults to `localhost`, the port fills in from DB_META (5432), and the password is empty so the URI has the user but no `:` — exactly the form most drivers accept. JDBC and the libpq key/value string are emitted because the database is PostgreSQL.

PostgreSQL with a special-character password and SSL

Input
db:       postgresql
host:     db.example.com
port:     5432
username: app_user
password: p@ss w0rd!:
database: production
SSL:      on
params:   connect_timeout=10
Output
Connection URI: postgresql://app_user:p%40ss%20w0rd!%3A@db.example.com:5432/production?sslmode=require&connect_timeout=10
JDBC URL:        jdbc:postgresql://db.example.com:5432/production?sslmode=require
libpq:           host=db.example.com port=5432 dbname=production user=app_user password=p@ss w0rd!: sslmode=require

Every character that is not URL-safe (`@`, space, `:`) is percent-encoded in the URI: `@` → `%40`, space → `%20`, `:` → `%3A`. The same password is left verbatim in the libpq line because libpq uses shell-style tokenisation, not URL encoding. SSL adds `sslmode=require` to both the URI and libpq, and the URI's query string merges the SSL flag with the user-supplied `connect_timeout=10` parameter.

MongoDB Atlas — `mongodb+srv` with TLS

Input
db:       mongodb
host:     cluster0.abcde.mongodb.net
username: user
password: p@ss
database: mydb
SSL:      on
SRV:      on
params:   retryWrites=true&w=majority
Output
Connection URI: mongodb+srv://user:p%40ss@cluster0.abcde.mongodb.net/mydb?tls=true&retryWrites=true&w=majority

With SRV enabled the scheme flips from `mongodb` to `mongodb+srv` and the port is dropped (SRV records resolve the port). The TLS flag is appended as `tls=true`, the supplied parameters are merged into the query string, and the password is percent-encoded — the `@` becomes `%40` so the URI stays parseable.

About this tool

Database connection strings are fiddly and database-specific: the scheme, credential placement, port and database joining, and — most commonly forgotten — percent-encoding special characters in passwords all vary. A single unencoded @ or : in a password breaks the URI. This builder turns a plain form into a correct, properly URL-encoded connection string for PostgreSQL, MySQL, MongoDB, Redis and SQLite.

Credentials are percent-encoded automatically, sensible default ports are pre-filled, and toggles cover SSL/TLS, MongoDB's mongodb+srv DNS seed-list format and arbitrary extra parameters. Where relevant the tool also emits a JDBC URL and a libpq keyword/value string, so you can paste the right form into your ORM, driver or CLI. Nothing you type — host, username or password — is ever transmitted or stored.

How to use

  1. Pick your database

    Choose PostgreSQL, MySQL, MongoDB, Redis or SQLite; the default port fills in.

  2. Fill in the details

    Enter host, credentials, database name and any extra parameters. Passwords are encoded for you.

  3. Toggle the options

    Enable SSL/TLS, or mongodb+srv for managed clusters like Atlas.

  4. Copy the string

    Copy the connection URI, or the JDBC / libpq variant, into your config.

Use cases

Onboarding a new dev onto the staging database

Pick PostgreSQL, fill in the shared staging host, port, username and password, and paste the resulting URI into your ORM or `psql` — no more typos in the `postgresql://...` form.

Migrating a Heroku-style URL into a JDBC driver

A common bug: an app stores a `postgres://` URL but the Java driver expects `jdbc:postgresql://...`. Paste the connection details once and copy the JDBC URL the tool emits — no manual scheme rewrite required.

Provisioning a connection for MongoDB Atlas

Atlas expects `mongodb+srv`, not `mongodb://`, and the URI must omit the port. Toggle SRV, paste the cluster host, and you have a copy-pasteable string for your application config.

Auditing how a connection string is built

When a service connects with a special character in the password, paste the parts in and read the URI to confirm the encoding is right — the diff between the libpq line and the URI is the clearest way to spot a missing percent-encoding.

Output formats

FormatUsed by
Connection URIMost drivers and ORMs (scheme://user:pass@host:port/db)
JDBC URLJava drivers for PostgreSQL and MySQL
libpq key/valuepsql and libpq-based Postgres clients
mongodb+srvMongoDB DNS seed-list connections

Credentials are URL-encoded automatically and never leave your browser.

Common mistakes

Mistake:Typing the password into the URI by hand and forgetting to URL-encode special characters.

Fix:An unencoded `@`, `:`, `/`, `?`, `#` or space silently corrupts the URI — the parser breaks at the wrong character. The builder always percent-encodes user/password with `encodeURIComponent`; trust the URI it emits, not your hand-typed copy.

Mistake:Putting a port after a `mongodb+srv://` host.

Fix:SRV records carry the port; adding `:27017` makes the URI invalid. The builder omits the port automatically when SRV is on, and disables the port input so you cannot type one in by mistake.

Mistake:Leaving the SQLite path blank.

Fix:SQLite's URI is a file path, not a network endpoint. The builder falls back to `database.db` in the working directory, which is rarely what you want in production — set the absolute path (e.g. `/var/data/app.db`) and the leading slashes are stripped so the URI becomes `sqlite:///var/data/app.db`.

Mistake:Using `ssl-mode=REQUIRED` (the MySQL form) on a PostgreSQL connection.

Fix:The two databases spell the parameter differently — Postgres uses `sslmode=require`, MySQL uses `ssl-mode=REQUIRED`. The builder picks the right one per database, so always copy the URI it emits instead of pattern-matching it onto another driver.

Frequently asked questions

References & standards