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
DATABASE_URLpostgresql://postgres@localhost:5432/myappParsed 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()");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.
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 | |
|---|---|---|---|---|
| disable | Local dev on a trusted network only | |||
| require | Encryption needed, cert verification not set up | |||
| verify-ca | CA only | You trust a specific CA but not the hostname | ||
| verify-full | Production over the internet - the safe default |
Common connection-string mistakes
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.
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.
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.
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.
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.
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.
Related developer tools
More free, browser-only tools for PostgreSQL and cloud storage.
Paste an EXPLAIN ANALYZE plan and get an interactive tree, slow-node highlighting, row-estimate checks, and plain-English fixes.
Open toolTurn CPU, RAM, and workload into a safe pool_size, max_connections, PgBouncer mode, and timeouts - with the math shown.
Open toolFind a safe max_connections and shared_buffers from your instance RAM, with per-connection memory accounted for.
Open toolCompare AWS S3, Cloudflare R2, Backblaze B2, Google Cloud, Azure, and Supabase side by side - storage, egress, and requests, with charts.
Open toolA 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.