Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>SQL tagged template literals (syntax only)New to Visual Studio Code? Get it now.
SQL tagged template literals (syntax only)

SQL tagged template literals (syntax only)

Jan Kuehle

|
23,981 installs
| (3) | Free
Syntax highlighting for SQL in template literals tagged with `sql` or `sqlFragment` function
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VS Code extension: SQL tagged template literals (syntax only)

A VS Code extension, which enables SQL syntax highlighting for template literals tagged with an sql or sqlFragment function in JavaScript and TypeScript files.

Image of code snippet showing SQL syntax highlighting

Supported are:

  • Tagged template literals:

    sql`SELECT * FROM user`;
    sqlFragment`WHERE id = ${id}`;
    
  • Functions returning a template tag:

    sql("get-user")`SELECT * FROM user`;
    sqlFragment("filter-by-id")`WHERE id = ${id}`;
    
  • Comments before template literals:

    /* sql * / `SELECT * FROM user`
    /* sqlFragment */ `WHERE id = ${id}`;
    
  • And most combinations with most TypeScript features. Some examples:

    sql<With, Generic<Types>>`SELECT * FROM user`;
    nested?.optional?.sql`SELECT * FROM user`;
    sql("with", Infinity, `params`)`SELECT * FROM user`;
    

If you're using PostgreSQL, have a look at SQL tagged template literals, which is the same extension but also supports SQL syntax validation, type checking and formatting.

Thanks

This is based on several great existing extensions:

  • https://github.com/mjbvz/vscode-comment-tagged-templates
  • https://github.com/ForbesLindesay/vscode-sql-template-literal
  • https://github.com/Ladeiras/vscode-sql-template-literal
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft