SQL Formatter

Paste your SQL query; indent it into a readable form and tidy up the keyword casing.

Runs 100% in your browser — your query is never sent to a server.

What Does the SQL Formatter Do?

This tool takes a SQL query that's been squeezed onto one line or inconsistently indented and turns it into a readable, consistent form: it puts each keyword (SELECT, FROM, WHERE, JOIN, etc.) on its own line, aligns subqueries and conditions, and formats according to the syntax of the dialect you choose (MySQL, PostgreSQL, T-SQL, SQLite, or general-purpose ANSI SQL). You can also set the keyword casing and the indent width (2 or 4 spaces) to your own preference.

When it's useful: when you need to quickly understand a complex, multi-line query someone else wrote during a code review; when you want to clearly see which table a JOIN or WHERE condition belongs to while debugging; when you want to turn a single-line auto-generated query — produced by an ORM or a legacy system — into something readable enough for documentation or a presentation; or when you want to keep a team's SQL style (keyword casing, indentation) consistent.

There are small differences between SQL dialects that affect formatting: MySQL uses backtick-quoted (`column_name`) identifiers, T-SQL has dialect-specific expressions like TOP N, and PostgreSQL commonly uses a RETURNING clause. Picking the right dialect lets the formatter recognize these constructs and indent them correctly; if you're not sure, the general SQL (ANSI) option works fine for most standard queries.

The SQL text you enter is parsed and reformatted entirely in your browser; no query, table name or column name is ever sent to a server or stored anywhere — this matters especially when formatting queries that contain sensitive production schema information. The tool only rearranges the text; it never connects to any database to run the query, so it's a good idea to test the syntax in your own database client before using the formatted output. As soon as you close the page, the text you entered is also cleared from browser memory — nothing is kept anywhere.

Try This Next

Finished here? These might be your next step.

Frequently Asked Questions

Besides general-purpose ANSI SQL, syntax specific to MySQL, PostgreSQL, T-SQL (SQL Server), and SQLite is also recognized — pick your dialect and format.

No. It only parses the text and reformats it; it never connects to any database, and your query is never sent anywhere.

No. The formatter only adjusts whitespace, line breaks and indentation; it doesn't change the keywords, table/column names or conditions in your query. The query before and after formatting represents exactly the same operation for the database.

Yes — since the process runs entirely in your browser, you're practically only limited by your browser's memory; long script files containing multiple statements can also be formatted. Formatting very large files may take a few seconds.

This option controls whether SQL keywords like SELECT/FROM/WHERE appear in the output in UPPER case, lower case, or unchanged as you typed them. It's useful for following a team coding standard or improving readability to your own taste; table/column names are not affected by this setting.

Last updated: