Sign In

TypeORM Database Connection Generator

Securely generate TypeORM connection URLs and configuration objects for PostgreSQL, MySQL, and MongoDB.

Connection String Generator

Live URI Preview

postgresql://admin:secret_password@localhost:5432/my_database

⚠️ Note: Special characters in your username or password are automatically URI-encoded to prevent connection parsing errors.

import { DataSource } from "typeorm"

export const AppDataSource = new DataSource({
  type: "postgresql",
  host: "localhost",
  port: 5432,
  username: "admin",
  password: "secret_password",
  database: "my_database",
  synchronize: true,
  logging: false,
  entities: [],
  subscribers: [],
  migrations: [],
})

Database Credentials

Secure TypeORM Database Configurations

Connecting your application to a database is often the very first technical step in backend development, yet it remains a surprisingly frequent source of frustrating deployment errors. Database connection strings (also known as Connection URIs) follow a strict, standardized format dictated by RFC 3986.

However, when secure database usernames or passwords contain special characters—such as @, :, /, or #—those specific characters must be properly URI-encoded (percent-encoded). Failure to do so causes the database driver (like `pg` or `mysql2`) to parse the connection string incorrectly, splitting the credentials at the wrong index. This results in immediate authentication failures or confusing "host not found" errors in production.

This developer tool securely generates perfectly formatted database connection credentials directly in your browser. Because the encoding mathematics happen entirely client-side, your sensitive credentials are never transmitted over the network to our servers. Whether you're connecting to PostgreSQL, MySQL, MongoDB, or Redis, we automatically handle the complex URI encoding and format the output code specifically for your chosen ORM or backend driver.

Configuring TypeORM DataSources

TypeORM is one of the most mature and widely adopted Object-Relational Mappers (ORMs) in the Node.js and TypeScript ecosystem, heavily utilized by enterprise architectures like the NestJS framework. While TypeORM does support parsing standard raw connection URIs, it is most commonly and robustly configured using the explicit DataSource configuration object.

Defining a strict DataSource object provides significantly more flexibility than a raw string URI, allowing you to easily define connection pooling limits, SSL certificates, migration directories, and event subscriber configurations in a type-safe manner. Our TypeORM generator bypasses the URI string entirely, directly exporting a ready-to-use TypeScript DataSource configuration block. It automatically maps your database engine to the correct TypeORM type literal and ensures network port numbers are correctly cast as integers rather than strings.

Frequently Asked Questions

Why is my connection string failing with an authentication error?

The most common cause of an authentication error, assuming the password is correct, is failing to URI-encode special characters. If your password contains an `@` symbol, the database driver thinks that is the end of the password and the beginning of the host URL. This tool automatically URL-encodes your password to prevent this.

Is it safe to type my database password here?

Yes. This application operates entirely on the client side (in your web browser). Your credentials are never sent via API requests or saved to any database. You can inspect the network tab in your browser's developer tools to verify no data is transmitted.

What does URL encoding do to my password?

URL encoding (or percent-encoding) converts reserved characters into a format that can be safely transmitted over the internet or parsed by standard URI parsers. For example, a space becomes `%20`, and an `@` symbol becomes `%40`. The database driver decodes it back to the original character before checking the password.

Related Tools