glunty

SQL Formatter and Beautifier

Format messy SQL into clean, readable queries. Runs fully in your browser.

Want to know what a query actually does? Pair this with the AI SQL query explainer: format first to make it readable, then get a clause-by-clause walkthrough in plain English.

What this tool does

Takes any SQL query and reprints it with consistent indentation, line breaks, and keyword casing, turning a one-line or badly spaced statement into something you can read, review, and diff. You control the SQL dialect, whether keywords come out uppercase or lowercase, and the indent width. Everything runs in your browser using the open-source sql-formatter library. Your query is never uploaded, logged, or stored. Once the page has loaded, it works offline.

How to use it

Paste a query into the input box. Choose the dialect that matches your database (the default Standard SQL covers most cases), pick a keyword case, and pick an indent style. Press Format, or hit Ctrl+Enter (Cmd+Enter on a Mac). The cleaned-up query appears in the output box; use Copy result to grab it. For example, paste select id,name from users where id=1, keep the UPPERCASE default, and you get a multi-line result with SELECT, FROM, and WHERE each on their own line. If the query cannot be parsed, the status line shows the parser's message instead of mangled output.

Common use cases

  • Reformatting a long query that arrived on a single line from a log or an ORM.
  • Making a query readable before code review so the diff shows real changes, not spacing.
  • Standardizing keyword case and indentation across a team's SQL files.
  • Cleaning up generated SQL from a query builder so a human can check it.
  • Preparing a messy query for the AI SQL explainer so the walkthrough is clearer.

Common pitfalls

  • Formatting is not validation. A query that formats cleanly can still be logically wrong or reference a table that does not exist. The formatter checks syntax enough to lay the query out; it does not run it or check your schema.
  • Pick the right dialect. Vendor extensions parse differently. PostgreSQL JSON operators, MySQL backtick identifiers, SQL Server bracketed names, BigQuery structs, and Oracle PL/SQL blocks may fail to parse under Standard SQL. Choose the matching dialect and format again.
  • Keyword case affects keywords only. Setting UPPERCASE changes words like SELECT and JOIN, not your table or column names. Identifiers inside quotes are always left exactly as written, because they can be case-sensitive.
  • Errors are expected on broken input. An unclosed string, an unbalanced parenthesis, or a stray token will stop formatting. That is the tool refusing to guess, not a bug. Read the message, fix the query, and retry.

Frequently asked questions

What is a SQL formatter and beautifier?
A SQL formatter takes a query written on one line or with inconsistent spacing and rewrites it with consistent indentation, line breaks, and keyword casing. The result is easier to read, review, and diff. This tool uses the open-source sql-formatter library and runs entirely in your browser, so no query ever leaves your machine.
Does formatting change what my query does?
No. Formatting only changes whitespace, line breaks, and the letter case of keywords such as SELECT and FROM. It does not rewrite logic, reorder clauses, add or remove columns, or touch string literals. The formatted query is equivalent to the original and returns the same results. Keyword casing is cosmetic in standard SQL, and text inside quotes is always left untouched.
Which SQL dialect should I choose?
Pick the dialect that matches the database you target. The default Standard SQL setting handles most common queries, but vendor extensions parse differently: PostgreSQL JSON operators, MySQL backtick identifiers, SQL Server bracketed names, BigQuery arrays and structs, and Oracle PL/SQL blocks. Choosing the right dialect lets the formatter indent those constructs correctly instead of tripping over them.
Why did formatting fail with an error?
The formatter parses your SQL before it can lay it out. If the query has a syntax error, an unbalanced parenthesis, an unclosed string, or a construct the chosen dialect does not recognize, parsing fails and the tool shows the parser message instead of silently producing broken output. Fix the reported problem, or try a different dialect, and format again.
Is the SQL I paste here sent to a server?
No. Formatting happens locally using a JavaScript library bundled into the page. Your query is never uploaded, logged, or stored. Once the page has loaded you can disconnect from the network and the formatter still works. You can verify this in DevTools under the Network tab: formatting a query makes zero requests.
How is this different from the SQL query explainer?
The formatter is purely mechanical: it reshapes whitespace and casing in your browser with no network calls. The SQL query explainer is an AI-assisted tool that reads a query and describes what each clause does in plain English. Format first to make a messy query readable, then send it to the explainer if you also want to understand it. The two tools pair well together.
Can it handle CTEs, window functions, and very long queries?
Yes. Common table expressions (WITH ... AS), subqueries, window functions (OVER PARTITION BY), CASE expressions, and multi-statement scripts are all indented sensibly. Long queries format in-browser with no size limit, though extremely large scripts may take a moment on low-powered devices.

Embed this tool

Free for any use; attribution appreciated. Paste this on your site:

The embed runs the same tool that lives at this URL. No tracking; no ads inside the embed. Resize height as needed for your layout.

Cite this tool

For academic, journalistic, or technical references. Pick a format:

Citations use 2026 as the publication year. Access date is left as a fillable placeholder where the citation style expects one.

Embedded tool from glunty.com