inyourbrowser.com

SQL query formatter

Format SQL queries for any major database system. Choose your dialect and the formatter will apply the correct indentation style and keyword casing conventions for PostgreSQL, MySQL, T-SQL, or standard SQL.

Dialect:

Formatting runs entirely in your browser.

How it works

The tool uses the sql-formatter library, a dialect-aware SQL pretty-printer that runs entirely in your browser. It parses your query and re-emits it with consistent indentation and capitalisation.

Example

Input

with x as (select a, row_number() over (partition by b order by c) rn from t) select * from x where rn = 1

Formatted

WITH
  x AS (
    SELECT
      a,
      row_number() OVER (
        PARTITION BY
          b
        ORDER BY
          c
      ) rn
    FROM
      t
  )
SELECT
  *
FROM
  x
WHERE
  rn = 1

Processing runs in your browser

All formatting happens locally in your browser tab. Our servers are not involved at any point.

Related operations

For inspecting JSON returned by queries, try the JSON formatter. To validate identifier patterns in your SQL, use the regex tester. For converting query results into structured rows, see CSV to JSON.

Frequently asked questions

What is the difference between SQL dialects?
Different database systems extend standard SQL with their own syntax and functions. MySQL, PostgreSQL, and T-SQL all have differences in data types, functions, and certain syntax forms. Choosing the correct dialect ensures the formatter handles these correctly.
How do I format a PostgreSQL query?
Click the 'PostgreSQL' dialect button, paste your query, and click Format SQL. PostgreSQL-specific keywords and syntax will be handled appropriately.
Can I use this to format stored procedures?
Paste the statements inside the procedure on their own: SELECT, INSERT, UPDATE, CTEs, subqueries and window functions all format normally. The sql-formatter library does not support stored procedure bodies, so a whole CREATE PROCEDURE block comes out with its BEGIN ... END body unindented.
Which dialect should I pick for SQLite, Oracle or BigQuery?
Pick Standard SQL, which covers the syntax most databases share. The tool offers only Standard SQL, MySQL, PostgreSQL and T-SQL, so database-specific syntax outside those can fail to parse; the tool then reports the line and column where parsing stopped.

Last reviewed September 30, 2026

Other pages for this tool

Related tools

Regex tester
Test regular expressions with a live match list, replace, and split modes. Runs in your browser.
YAML formatter
Format, validate, and convert YAML. Compatible with Kubernetes, CI configs, and OpenAPI files.
JSON formatter
Pretty-print, minify, validate, and sort JSON keys. Instant output.