Inline SQLA Visual Studio Code extension that provides syntax highlighting, autocomplete, validation, and formatting for SQL strings embedded in your code. No markers or special tags required — SQL is detected automatically. Getting StartedRequires VS Code 1.85 or later. To install a locally built release, run Extensions: Install from VSIX... from the Command Palette and choose the Open a supported source file containing SQL, for example:
SQL highlighting, keyword completion and validation work without a database connection. Place the cursor inside the string and run Inline SQL: Format SQL at Cursor, or use Inline SQL: Format All SQL in File. To share formatting preferences with other tools, add the configuration file described below. See CHANGELOG.md for release notes and CONTRIBUTING.md for development and packaging instructions. Supported Languages
FeaturesSyntax HighlightingSQL keywords, types, functions, and literals are highlighted inside string literals with categorized colors. Works with both light and dark themes. Autocomplete
Triggers on Validation / Linting
Formatting
Commands
SettingsAll settings are under the Detection
Validation
When set to
Formatting
These formatting settings can be set per workspace folder. Formatting and validation have separate dialect settings: Shared
|
| Setting | Type | Default | Description |
|---|---|---|---|
inlineSql.connections |
array | [] |
Database connections |
inlineSql.activeConnection |
string | "" |
Active connection name |
inlineSql.schemaCacheTTL |
integer | 300 |
Cache TTL in seconds; range 1–86400 |
Define connections in User settings (machine scope), not repository settings. Database access and loading optional drivers require a trusted workspace, following the VS Code Workspace Trust guide. Set passwordEnv to an environment variable available to the VS Code extension host; plaintext password remains supported but is deprecated.
Connection object:
{
"inlineSql.connections": [
{
"name": "local-dev",
"driver": "postgres", // postgres | mysql | mssql
"host": "localhost",
"port": 5432,
"database": "mydb",
"user": "dev",
"passwordEnv": "INLINE_SQL_DB_PASSWORD"
}
],
"inlineSql.activeConnection": "local-dev"
}
Note: Database drivers (
pg,mysql2,mssql) must be installed in your workspace for schema features to work.
| Driver setting | Package to install | Default port |
|---|---|---|
postgres |
pg |
5432 |
mysql |
mysql2 |
3306 |
mssql |
mssql |
1433 |
Connection objects require name, driver, host and database; port, user, passwordEnv and the deprecated password are optional. When passwordEnv is set, it takes precedence over password; an undefined environment variable prevents the connection. With remote development, install the driver and provide the environment variable where the extension host runs.
Schema completion refreshes expired metadata on demand. Use Inline SQL: Refresh Schema Cache after changing credentials or when an immediate refresh is needed. Database queries read schema metadata; the extension does not execute the SQL strings from your source files.
Troubleshooting
| Symptom | What to check |
|---|---|
| Shared formatting settings are ignored | Save .sql-formatter.json, verify it is in the source directory or a parent within the workspace, and check for a nearer configuration file. |
| Formatting reports invalid configuration | Use strict JSON, supported option names and valid values. The warning identifies the configuration file; source code is left unchanged. |
| A SQL string is left unchanged | Host-language escapes, multiline SQL values and single-line raw strings are not safely rewritten. The formatter also may not support the SQL syntax or selected dialect. |
| Formatting asks you to run the command again | The source document changed while configuration was being read. Retry on the current document. |
| No database table or column suggestions | Check workspace trust, User settings, the active connection name, driver installation and the environment variable used by passwordEnv. |
| Formatting succeeds but validation warns | Check the separate validation dialect. Validation uses a SQL parser and skips some unsupported fragments and procedural statements; it does not validate against a live database. |
How It Works
- String Extraction — Language-specific parser extracts all string literals, handling comments, escape sequences, and nested interpolations
- Interpolation Replacement — Template expressions are replaced with SQL-safe placeholders for parser compatibility
- Classification — Two-tier approach:
- Fast path: String starts with a SQL keyword (
SELECT,INSERT,CREATE, etc.) - Scoring: String meets
inlineSql.detection.minKeywords(default: 2), includes a qualifying statement keyword, and is at least 20 characters
- Fast path: String starts with a SQL keyword (
- Highlighting — Decoration API provides categorized highlighting compatible with semantic tokenization.
License
MIT