SQL Formatter (beautify queries)

Paste a tangled or minified SQL query and instantly get a tidy version with clear indentation and aligned keywords, making it much easier to read and review. Choose the dialect (Standard SQL, MySQL, PostgreSQL, MariaDB, SQLite, SQL Server, Oracle, BigQuery, Snowflake, Redshift or Spark), the indent size, and whether keywords appear in uppercase or lowercase. Everything happens in your browser: your query is never uploaded to any server.

How to format SQL

  1. Paste your SQL query into the box on the left.
  2. Choose your database dialect (Standard SQL, MySQL, PostgreSQL, SQL Server, Oracle…).
  3. Adjust the indentation and whether keywords should be uppercase, lowercase or left as written.
  4. The formatted SQL appears instantly on the right; copy it with “Copy” or download it as .sql.

Frequently asked questions

What does a SQL formatter do?

It rewrites a SQL query with a clear, consistent structure — line breaks, indentation and aligned keywords — without changing what it does. It turns a long or minified query written on a single line into readable text that is easier to understand, review and debug.

Is my query uploaded to a server?

No. Formatting happens entirely in your browser using JavaScript; your SQL never leaves your device, and the tool works offline once it has loaded. It is safe for queries containing table names, column names or sensitive data.

Which SQL dialects are supported?

Standard SQL, MySQL, PostgreSQL, MariaDB, SQLite, SQL Server (Transact-SQL), Oracle (PL/SQL), BigQuery, Snowflake, Amazon Redshift and Spark SQL. Choosing the right dialect improves the formatting of each engine's own syntax. It uses the conversion from the open-source library sql-formatter (MIT).

Can I make keywords uppercase?

Yes. You can turn keywords (SELECT, FROM, WHERE, JOIN…) into UPPERCASE, lowercase, or keep them exactly as typed. This is a very common style convention: uppercase keywords are easier to tell apart from table and column names at a glance.

Does formatting change my query's result?

No. It only rearranges spacing, line breaks and indentation, and optionally the letter case of keywords. The query logic, names, string literals and comments are all kept intact.

Why do I get an error when formatting?

The formatter needs to parse the SQL syntax. If the query has an error (an unclosed parenthesis, a stray quote, or a token it does not recognize), it shows the approximate line and column so you can fix it. Also try switching the dialect if you are using syntax specific to your engine.

Can I minify SQL (put it on one line)?

This tool focuses on beautifying for readability. Minifying SQL brings little benefit, since the server parses it the same either way, and doing it incorrectly can break comments or literals that contain spaces — so we prefer not to offer a minifier that could corrupt your query.