DBX

SQL Formatting

DBX chooses a formatter dialect from the active connection and writes the result back to the query editor. When text is selected, only that range is formatted; otherwise DBX formats the entire editor.

Use the Format SQL toolbar button or the configurable formatting command documented under Keyboard Shortcuts.

Formatting only rewrites text and never executes SQL. Unsupported syntax returns an error and leaves the original text unchanged. One formatting operation accepts at most 1,000,000 characters.

Dialect Selection

DBX currently uses dedicated formatter grammars for:

Connection typeFormatter dialect
MySQLMySQL
PostgreSQL, openGauss, GaussDB, KingbaseES, Redshift, and related profilesPostgreSQL
SQLite, Turso, rqlite, and Cloudflare D1SQLite
SQL ServerTransact-SQL
ClickHouseClickHouse
Other SQL databasesGeneric SQL, with one PostgreSQL-grammar retry when needed

The MongoDB query editor uses a separate Mongo Shell formatter rather than this SQL dialect mapping.

Configure Formatting Options

Open Settings → SQL Formatter. Form mode exposes:

OptionValues or behavior
Keyword, data type, function, and identifier caseupper, lower, or preserve
Indent stylestandard, tabularLeft, or tabularRight
IndentationSpaces or tabs
Tab width2 or 4
Logical operator newlineBefore or after the operator
Expression width50, 80, or 120
Lines between queries0, 1, or 2
Dense operatorsReduces spaces around operators
Newline before semicolonPlaces a statement-ending semicolon on a new line
Parameter typesRecognizes positional, numbered, named, quoted, or custom-regex parameters

Restore Defaults restores the formatter settings defined by the current DBX build. Click Apply in the settings dialog to persist changes.

JSON Mode and Import / Export

JSON mode is useful for exact editing, copying, or moving formatter settings. The current file contains only version, formatter, and options:

{
  "version": 1,
  "formatter": "sql-formatter",
  "options": {
    "keywordCase": "upper",
    "dataTypeCase": "preserve",
    "functionCase": "preserve",
    "identifierCase": "preserve",
    "indentStyle": "standard",
    "useTabs": false,
    "tabWidth": 2,
    "logicalOperatorNewline": "before",
    "expressionWidth": 50,
    "linesBetweenQueries": 1,
    "denseOperators": false,
    "newlineBeforeSemicolon": false,
    "paramTypes": null
  }
}

The JSON editor validates the draft continuously. DBX blocks apply or import when:

  • the text is not valid JSON;
  • version is not 1;
  • formatter is not sql-formatter;
  • options contains an unknown field; or
  • a value is outside the range accepted by the current build.

Export Config downloads dbx-sql-formatter.json. Import replaces only SQL formatter options; it does not change connections, editor shortcuts, or other DBX settings. Use Configuration Cloud Sync when you need a broader settings migration.

Parameter Recognition

Set paramTypes to null to use the formatter defaults. Configure additional parameter syntax with an object such as:

{
  "positional": true,
  "numbered": ["?", "$"],
  "named": [":", "@", "$"],
  "quoted": [":", "@", "$"],
  "custom": [
    { "regex": "@\\{[^}]+\\}" }
  ]
}
  • numbered accepts only ?, :, and $.
  • named and quoted accept only :, @, and $.
  • Each custom item may contain only a non-empty, valid regex.

DBX always adds recognition for ${name} and #{name} variables so those templates do not cause formatter parse failures. A non-null legacy params option is no longer used for text substitution; configure paramTypes instead.