SQL Validator

An SQL syntax checker for MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, and BigQuery. It points to the line and column of the first error and says what the parser expected there.

Checked in your browser. Your SQL is not uploaded.
Dialect
MySQL parser loads on the first check (293 KB)

Report

Ready to check

Press Validate. The parser for the chosen dialect downloads once, then every check runs instantly.

  • Line and column of the first error
  • What the parser expected at that point
  • Statement count by type
Only the syntax is checked. Table and column names are not looked up. Press Ctrl + Enter to validate.

How to use the SQL Validator

  1. Choose the database the SQL is written for.
  2. Paste one or more statements separated by semicolons, or upload a .sql file up to 1 MB.
  3. Press Validate. The first press loads the parser for that dialect.
  4. If there is an error, the excerpt under the message marks the spot with a caret. Fix it and validate again.

How it works

The check uses node-sql-parser, an open-source parser with a separate grammar for each dialect. Each grammar is about 230 to 330 KB, so only the one you pick is downloaded, and it runs in your browser.

The parser reads the statements from the start and stops at the first token that its grammar does not allow. Its list of what it would have accepted can be long and technical. The tool shortens it: comment markers and whitespace are dropped, character classes become "a name" or "a number", and keywords are shown in capitals.

A valid result lists how many statements of each type were found, such as SELECT 2, UPDATE 1.

Examples

  • SELECT a,, b FROM t fails with Unexpected "," at line 1, column 10. The parser expected a column name or an expression after the first comma.
  • SELECT * FROM fails with The query ends before it is complete, because a table name has to follow FROM.
  • SELECT 'abc FROM t reports A quoted string is never closed.
  • INSERT INTO t (a) VALUES (1) RETURNING a passes as PostgreSQL. As MySQL it fails, since MySQL has no RETURNING clause.

Limitations

  • Syntax only. Table and column names are not looked up, so a misspelled table still passes.
  • Only the first error is reported. Fix it and validate again to find the next one.
  • The grammars cover the common parts of each dialect. Rare vendor syntax, procedural code such as PL/pgSQL bodies, and very new keywords can be reported as errors even when your database accepts them.
  • Oracle is not among the dialects.

Frequently asked questions

Can this tell me why my query returns the wrong rows?

No. It checks that the SQL is well formed. Wrong results come from the logic of the query or the data, which only running it can show.

Is my SQL sent to a server?

No. The parser runs in your browser, so table names and literal values in the query stay on your device.

Why does it reject SQL that works in my database?

The dialect may be set wrong, or your database accepts an extension the grammar does not know. Try the exact dialect, and treat the result as a hint rather than the final word.

Often used together with SQL Validator.

  • SQL Formatter

    Formats SQL queries for MySQL, PostgreSQL, SQLite, SQL Server, and more.

  • SQL Minifier

    Removes comments and extra whitespace from SQL, keeping strings and optimizer hints intact.

  • SQL Query Generator

    Generates CREATE, INSERT, SELECT, UPDATE, and DELETE statements for four databases.