SQL Syntax Checker

Paste a query to find the quote, bracket or dialect-specific token that will make your database reject it. Choose the dialect first, because what is valid in MySQL can be an error in PostgreSQL.

Input

Settings

History

Load from URL

What the checker catches

The checker reads your SQL with a tokenizer that knows each dialect’s quoting and comment rules, then runs the sql-formatter parser over the result. Together they catch the errors that usually come from copy-paste and string building:

  • Unterminated strings: WHERE city = 'Singapore AND vip = true. The message points to the opening quote and reminds you that a quote inside a string is doubled ('O''Brien'), or escaped with a backslash in MySQL.
  • Unbalanced brackets: an opening ( that is never closed, a stray ), or a ] where a ) was expected. The position of the unmatched bracket is reported, not the end of the file.
  • Unclosed block comments: a /* without */ silently comments out the rest of a script.
  • Statements cut off mid-clause: a script that ends with DELETE FROM orders WHERE is reported as “The statement ends with “WHERE” but nothing follows it”. Run as-is, that kind of truncated statement is at best an error and at worst a different query.
  • Syntax from the wrong dialect: backtick identifiers checked as PostgreSQL, or [bracketed] names checked as Standard SQL. These come back as warnings that name both the syntax and the dialect, such as “Backtick-quoted names like id are not PostgreSQL syntax”, with a hint listing the dialects that do accept it. Text the parser cannot read at all is a hard error instead.

Pick the right dialect

The Dialect option decides what counts as valid. Standard SQL is strict; choose MySQL, PostgreSQL, T-SQL (SQL Server), PL/SQL (Oracle), SQLite, MariaDB, BigQuery, Snowflake, Amazon Redshift, Spark SQL, Trino / Presto or IBM DB2 to match your database. The same query can flip from valid to invalid: 'O\'Brien' is a complete string in MySQL, while PostgreSQL reads the backslash literally and reports the string as unterminated. Common placeholders such as $1, :since and @customerId are accepted. Dialect-specific quoting is understood as well: PostgreSQL dollar-quoted bodies ($tag$ it's fine $tag$) can contain unescaped quotes, and BigQuery accepts table paths with dashes when they are wrapped in backticks, as in a project named my-project.

Errors appear as you type, with the line and column highlighted in the editor and a one-line hint. The formatted query from the last successful check stays in the output pane, dimmed, so a half-typed edit does not wipe your view.

Limits worth knowing

This is a syntax checker that runs without a database, so it cannot know your schema. A misspelled table or column name, a missing GROUP BY column, a type mismatch or a permission problem will only show up when the query runs. The parser is also forgiving in places: a dangling comma as in SELECT id, FROM users is not rejected, and a misspelled keyword such as SELEC can be read as an identifier. Treat a pass as “no broken quotes, brackets or foreign syntax”, then run EXPLAIN against a real database for anything that matters.

Queries often contain customer data or credentials in connection strings. Checking happens in the browser and nothing is uploaded, so production SQL is safe to paste.

Examples

Unclosed string in a filter

Invalid: the quote before Singapore is never closed, so the rest of the query would be read as part of the string.

Input
SELECT id, name, email
FROM customers
WHERE city = 'Singapore AND vip = true
ORDER BY name;
Result
Line 3, column 14: This string is never closed — the ' has no matching '
Open this example in the tool

Missing parenthesis in an aggregate

Invalid: the ‘(’ after SUM is never closed, and the error points at that bracket rather than at the end of the query.

Input
SELECT o.id, SUM(i.qty * i.price AS total
FROM orders o
JOIN order_items i ON i.order_id = o.id
GROUP BY o.id;
Result
Line 1, column 17: This '(' is never closed
Open this example in the tool

DELETE cut off after WHERE

Invalid: nothing follows WHERE, so the statement is reported as incomplete instead of being formatted.

Input
DELETE FROM sessions
WHERE
Result
Line 2, column 1: The statement ends with "WHERE" but nothing follows it
Open this example in the tool

MySQL backticks checked as PostgreSQL

Parses with a warning: PostgreSQL quotes identifiers with double quotes, and the hint suggests MySQL, MariaDB, BigQuery or Spark SQL.

Input
SELECT `id`, `email` FROM `users` WHERE `active` = 1;
Output
SELECT
  `id`,
  `email`
FROM
  `users`
WHERE
  `active` = 1;
Open this example in the tool

Common errors and how to fix them

ErrorCauseFix
This string is never closed — the ' has no matching '
Explained
A string literal is missing its closing quote, often because a value like O’Brien contained an unescaped quote.Close the string, and double any quote inside it (‘O’‘Brien’).
This '(' is never closed
Explained
A function call, IN list or subquery is missing its closing parenthesis.Add the matching ‘)’ where the expression ends.
Unexpected ')' — there is no matching '(' before it
Explained
An extra closing parenthesis, usually left behind after editing a condition.Remove it, or add the opening bracket it was meant to close.
The statement ends with "WHERE" but nothing follows itA statement was truncated mid-clause, often by a copy that stopped short or a string-built query with an empty condition.Complete the clause, or remove the dangling keyword.
Backtick-quoted names like `id` are not PostgreSQL syntaxA warning: the query uses identifier quoting from another database while PostgreSQL is selected.Switch the Dialect option to the database you use, or quote names with double quotes for PostgreSQL.
This /* comment is never closedA block comment has no closing */, so everything after it is ignored by the database.Add */ where the comment should end.

Frequently asked questions

Does the SQL checker connect to my database?

No. It works entirely in the browser from the query text, so it cannot check table names, columns or permissions.

Why does my query pass here but fail in the database?

The database also checks names, types and clause rules against your schema. A pass here means the quoting, brackets and dialect syntax are sound, not that the query will run.

Can it check a whole migration script with many statements?

Yes. Paste the full script; each statement is checked and errors report the line within the script. T-SQL GO separators and PL/SQL blocks are understood when the matching dialect is selected.

Which dialect should I choose for Amazon Aurora or Azure SQL?

Aurora is MySQL- or PostgreSQL-compatible, so pick the engine your cluster runs. Azure SQL Database uses T-SQL (SQL Server).

Related tools