Parse DSN

Parse a database DSN into scheme, host, port, credentials, path, and options.

freeworks offlinenothing uploaded
ToolDSN Parser
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

URI delimiters split scheme, authority, credentials, host, port, path, and query parameters; percent-encoded components are decoded at field boundaries. Driver aliases are mapped to normalized fields.

  • URI separators keep fields unambiguous.
  • Normalized fields allow different drivers to be compared.

Worked example

PHP PDO DSN
Parse a PHP PDO-style data source name string
Input
											mysql:host=localhost;port=3306;dbname=myapp;charset=utf8mb4
										
Output
												Driver: mysql
Host: localhost
Port: 3306
Database: myapp
Charset: utf8mb4
Format: php-pdo

PARAMETERS
Host: localhost
Port: 3306
Dbname: myapp
Charset: utf8mb4
											

When to use this

DATABASE_URL parsing, migration dashboards, and secret scanners parse DSNs.

Edge cases

  • An @ in a password must be encoded.
  • A Unix socket path can replace a TCP host.
  • Repeated query parameters need a defined list or last-value policy.

References