codemirror-sql

by marimo

A CodeMirror extension for SQL with real-time syntax validation and error diagnostics using node-sql-parser.

SQL Editor with Diagnostics

Try typing invalid SQL syntax to see real-time error highlighting and messages. Valid tables are: users, posts, orders, customers, categories

Put the cursor on a CTE name or alias to highlight its references, Cmd/Ctrl-click (or F12) to jump to its definition, and press F2 to rename it everywhere in the statement.

Example Queries

Click any example to load it into the editor:

Valid Queries

Invalid Queries (will show errors)

Features

Real-time Validation

SQL syntax is validated as you type with a configurable delay (750ms default).

Error Highlighting

Syntax errors are highlighted with red underlines and detailed error messages.

Multiple SQL Dialects

Supports MySQL, PostgreSQL, MariaDB, SQLite, Snowflake, and DuckDB syntax validation.

DuckDB Support

Special support for DuckDB-specific syntax like "from table select * limit 100".

CTE & Alias Navigation

Go-to-definition (Cmd/Ctrl-click or F12), reference highlighting, and rename (F2) for CTE names, table aliases, and select aliases.

CTE Autocomplete

Statement-scoped completion of CTE names and their output columns, including after my_cte..

TypeScript Support

Full TypeScript support with comprehensive type definitions.