Postgres Connection String Generator
Enter your host, port, database and credentials once and get a correct PostgreSQL connection string in every format you need: libpq URI, keyword/value DSN, psql command, JDBC URL, psycopg 3, SQLAlchemy, node-postgres, Go pgx, Npgsql and .env variables. Special characters in usernames and passwords are percent-encoded automatically, and you can paste an existing URI to convert it. Everything runs in your browser — credentials are never uploaded.
Do more than postgres connection string generator — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Fill in host, port, database, user and password, and pick an sslmode if your server requires TLS.
- Or paste an existing postgresql:// URI and hit Parse to populate the fields from it.
- Copy the connection string in the format your client needs — URI, DSN, JDBC, Python, Node.js, Go, .NET or .env.
Frequently asked questions
What is the PostgreSQL connection string format?
PostgreSQL accepts two formats. The URI form is postgresql://user:password@host:port/dbname?sslmode=require, and the keyword/value DSN form is host=localhost port=5432 dbname=mydb user=app_user password=secret. Both are understood by psql and every libpq-based driver; JDBC uses its own variant that starts with jdbc:postgresql:// and passes the user and password as query parameters or separate properties.
How do I handle special characters in a Postgres password?
In the URI format, characters such as @, :, /, #, ? and % in the username or password must be percent-encoded — p@ss:word becomes p%40ss%3Aword — otherwise the URI parser splits the string in the wrong place. This generator encodes them automatically. In the keyword/value format no encoding is needed, but values containing spaces or quotes must be wrapped in single quotes.
Which sslmode should I use for a production database?
Use verify-full whenever possible: it encrypts the connection and verifies the server certificate and hostname, protecting against both eavesdropping and man-in-the-middle attacks. require encrypts but does not verify the certificate by default, and the default prefer silently falls back to an unencrypted connection if TLS fails. Managed providers like RDS, Supabase and Neon generally require at least sslmode=require. Once your string works, you can save the connection in Chat2DB, a free AI database client for Postgres and 20+ other engines — download at https://chat2db.ai/download or use the web version at https://app.chat2db.ai.
