MongoDB Connection String Builder
Fill in hosts, credentials and options to get a valid MongoDB connection URI — or paste an existing mongodb:// or mongodb+srv:// string to break it down into fields. Usernames and passwords are percent-encoded automatically, replica set and SRV rules are checked as you type, and ready-to-run snippets are generated for mongosh, Node.js, Python (PyMongo) and Java. Everything runs in your browser; no credentials are uploaded.
Do more than mongodb connection string builder — 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
- Choose mongodb:// or mongodb+srv://, enter one host per line (host:port), then your username, password and default database.
- Set options such as authSource, authMechanism, replicaSet, tls and readPreference — or paste an existing URI and click Parse to fill every field.
- Review the warnings, then copy the URI, masked URI, or the mongosh, Node.js, Python or Java snippet.
Frequently asked questions
What is the MongoDB connection string format?
The standard format is mongodb://user:password@host1:27017,host2:27017/mydb?replicaSet=rs0&authSource=admin. The seed list can hold several host:port pairs for a replica set or sharded cluster, the path sets the default database, and options follow the question mark. The DNS seed list format mongodb+srv://user:password@cluster0.example.net/mydb takes a single host name without a port; the driver looks up the members in DNS SRV records, reads options from a TXT record and enables TLS by default.
How do I encode special characters in a MongoDB password?
Characters such as @ : / ? # [ ] and % in the username or password must be percent-encoded, otherwise the driver splits the URI in the wrong place and fails with an authentication or parse error. For example p@ss:w/rd% becomes p%40ss%3Aw%2Frd%25. This builder applies encodeURIComponent to credentials automatically, and the parser decodes them back when you paste a URI.
When do I need authSource=admin?
authSource names the database where the user was created. When it is missing, the driver authenticates against the database in the URI path, and falls back to admin only when no database is given. Most users, including all MongoDB Atlas database users, are created in admin, so a URI like mongodb://user:pass@host/mydb fails with Authentication failed unless you add authSource=admin. X.509, AWS, Kerberos and LDAP users use $external instead. Once connected, you can browse and query MongoDB alongside SQL databases in Chat2DB — download it free at https://chat2db.ai/download.
