Free developer tool

PostgreSQL connection string generator & parser

Build a DATABASE_URL from its parts, or paste one to decode it - then copy a ready-to-run snippet for Node, Python, Go, Rust, Java, or PHP. Deterministic, and 100% in your browser, so a pasted password never leaves the tab.

  • Runs in your browser No server round-trip
  • No sign-up Nothing to install
  • Nothing is uploaded Your SQL never leaves the tab
  • Works offline After the page loads
Your DATABASE_URL
postgresql://postgres@localhost:5432/myapp

Parsed and generated entirely in your browser - your password is never uploaded.

Use it in your code

import { Pool } from "pg";

const pool = new Pool({
  connectionString: process.env.DATABASE_URL,
});

const { rows } = await pool.query("select now()");
Anatomy

Every part of a connection string

A DATABASE_URL is just a URL. Once you can see the parts, the confusing connection errors stop being confusing.

postgresql://schemeuserusername:passwordpassword@hosthost:5432port/dbdatabase?sslmode=requireparameters
SSL

Which sslmode to use

sslmode controls whether the connection is encrypted and whether the server's certificate is verified. Pick the strictest one your setup allows.

sslmode
Encrypted?
Verifies cert?
Use when
disableLocal dev on a trusted network only
requireEncryption needed, cert verification not set up
verify-caCA onlyYou trust a specific CA but not the hostname
verify-fullProduction over the internet - the safe default
Get it right

Common connection-string mistakes

01

Special characters in the password

An @, :, /, or space in a raw password breaks parsing. Percent-encode them (@ becomes %40). This tool does it for you - build the URL here rather than hand-editing.

02

Committing the URL to git

A DATABASE_URL contains a password. Keep it in an environment variable or secrets manager, reference it as process.env.DATABASE_URL, and add .env to .gitignore.

03

sslmode=disable in production

It sends your password and data in clear text. Use verify-full over the internet; managed hosts require SSL anyway, so disable will simply fail to connect.

04

Wrong port

Postgres defaults to 5432, but poolers change it: PgBouncer often listens on 6432, and some managed providers front the pooler on a different port than the direct database. Check whether you want the pooled or direct endpoint.

05

Pooled vs direct endpoints

Serverless and edge runtimes should use a pooled connection string (transaction pooling) to avoid exhausting connections. Long-lived servers can use the direct one. Using the wrong endpoint causes intermittent 'too many connections' errors.

06

Forgetting the database name

postgresql://user:pass@host:5432/ with no database connects to a default that may not exist. Always include the database segment after the port.

Connection string FAQ

What is the format of a PostgreSQL connection string?

postgresql://user:password@host:port/database?sslmode=require. The scheme can be postgresql:// or the shorter postgres://. Port defaults to 5432 if omitted. Everything after the ? is query parameters - most commonly sslmode, but also application_name, connect_timeout, and others.

Do I need to URL-encode my password?

Yes, if it contains characters like @, :, /, ?, #, or spaces. An un-encoded @ in a password will be read as the start of the host and the connection will fail with a confusing error. This tool encodes credentials automatically when it builds the URL, and decodes them when it parses one.

What sslmode should I use?

For anything over the public internet, use verify-full - it encrypts the connection and verifies the server certificate against its hostname, protecting against man-in-the-middle attacks. require encrypts but does not verify the certificate. disable turns SSL off and should only be used on a trusted local network. Managed providers like Swyftstack require SSL by default.

Is my connection string sent anywhere?

No. Parsing and generation happen entirely in your browser with JavaScript. Your host, username, and password are never uploaded, logged, or stored, and the tool works offline after it loads. Still, treat a connection string like a password - it usually contains one.

Why does DATABASE_URL work in some libraries but not others?

URL-style strings (postgresql://...) are understood by most modern drivers (node-postgres, psycopg, pgx, sqlx). JDBC uses a slightly different form (jdbc:postgresql://host:port/db?user=...&password=...) and PHP's PDO uses a DSN with semicolons. This tool generates the correct form for each - copy the snippet for your stack.

A connection string that just works.

Swyftstack gives you a copy-paste DATABASE_URL with SSL on by default and a pooled endpoint for serverless. Deployed in under a minute.