consolelog.tools

Database Connection String Builder

Build (or reverse-parse) connection strings for PostgreSQL, MySQL, MongoDB, Redis, and 4 more — live preview, env-var + code snippet.

About this ToolHow it works, benefits & use cases

Build a correct database connection string for eight engines — PostgreSQL, MySQL, MariaDB, MongoDB, Redis, Microsoft SQL Server, SQLite, and Oracle — from simple fields, and get the matching env-var line and client code alongside it. Pick an engine and the default port fills in automatically (5432, 3306, 27017, 6379, and so on); enter host, database, and username, and the URI assembles live with the username and password percent-encoded. Enabling SSL adds the right marker per engine (sslmode=require for Postgres, rediss:// for Redis, +srv for MongoDB, Encrypt=true for SQL Server). The output bundles three things: the connection URI, a ready-to-paste environment variable (DATABASE_URL, MONGODB_URI, REDIS_URL, etc.), and a copy-paste code example for that engine's common Node client. A reverse "Parse a URI" mode breaks an existing connection string back into its parts. Passwords live in memory only — they are never written to localStorage, the URL, or share links, and parsed passwords come back masked as ****.

How to Use

  1. 1Choose "Build from fields" mode and select your database type from the button row — the default port fills in for you.
  2. 2Enter host, port, database, username, and password (Redis and SQLite hide the fields they don't use), and toggle "Enable SSL/TLS" if needed.
  3. 3Click "Build connection string" to produce the URI; review any security warnings shown below.
  4. 4Copy the combined output — the URI, the environment-variable line, and the client code example for that engine.
  5. 5To go the other way, switch to "Parse a URI" mode, paste a connection string, then click "Use in builder" to load its parts back into the form.

Key Benefits

  • Eight engines: PostgreSQL, MySQL, MariaDB, MongoDB, Redis, MSSQL, SQLite, Oracle
  • Automatic default ports and engine-correct SSL markers (sslmode, rediss, +srv, Encrypt)
  • Username and password percent-encoded so special characters never break the URI
  • Bundled env-var line and ready-to-paste Node client code for each engine
  • Reverse "Parse a URI" mode decomposes an existing string into editable fields
  • Inline warnings for weak/default passwords and SSL disabled on non-local hosts
  • Password stays in memory only — never persisted to storage, URL, or share links

Common Use Cases

  • Assembling a DATABASE_URL for a new Postgres or MySQL service without misremembering the format
  • Generating a MongoDB +srv URI for an Atlas cluster with the right options
  • Producing a rediss:// string with TLS for a managed Redis instance
  • Decomposing a connection string from a config file to inspect host, port, and database
  • Getting starter client code (pg, mysql2, mongodb, ioredis, mssql, oracledb) for a new project

Password not saved. The password stays in memory only — never written to localStorage, the URL, or share links.

Database type

Live preview

-- Connection URI
postgresql://localhost:5432/mydb

-- Environment variable
DATABASE_URL="postgresql://localhost:5432/mydb"

-- Code example
// Node.js (pg)
import { Pool } from 'pg';

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

// TypeScript (Prisma)
// In .env file: DATABASE_URL="postgresql://localhost:5432/mydb"
// prisma/schema.prisma:
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools