Skip to content

SQL Formatter

Turn one-line SQL into a readable, indented query.

  • 100% Free
  • No Sign Up
  • Works in Your Browser

SQL formatter

Format SQL queries for readability

Keyword case

Indent

Everything runs in your browser. Nothing is uploaded.

More Developer Tools

View all tools

Every everyday developer tool, right in your browser.

No installs. No uploads. No signup.

Browse all 36 tools
Developer tools
36
Cheat sheets
10
Bytes uploaded
0

How to use the SQL formatter

Three steps, all in your browser.

  1. 1

    Paste your input

    Type or paste your code or data. Press Sample to try an example.

  2. 2

    Pick the style

    Choose indentation or options. The result updates as you type.

  3. 3

    Copy the result

    Copy the output in one click. Nothing is saved or sent anywhere.

SQL Formatter: what to know

The SQL formatter takes a query, often a single long line copied from a log, an ORM or a BI tool, and lays it out with each clause (SELECT, FROM, JOIN, WHERE, GROUP BY, ORDER BY) on its own line and columns and conditions indented beneath it. It uses the open-source sql-formatter library, which knows the keywords and syntax of many dialects.

Choose the dialect that matches your database. PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), BigQuery and others differ in quoting, operators and keywords, and picking the right one avoids odd line breaks around dialect-specific syntax such as PostgreSQL's :: casts or T-SQL's square-bracket identifiers.

Formatting only changes layout and keyword case. The query isn't run or checked against a schema, so a misspelled table formats as happily as a correct one, and nothing about your database is needed or sent anywhere.

Popular uses

  • Reading queries generated by an ORM or found in slow-query logs
  • Making SQL readable in code reviews and pull requests
  • Formatting queries for documentation and runbooks
  • Untangling long reporting queries with many joins

Tips for the best result

  • Consistent keyword case (UPPER for keywords, lower for identifiers) makes queries easier to scan in reviews.
  • Parameter placeholders such as ?, $1 or :name are kept as they are.
  • If formatting looks wrong around one statement, check that the dialect matches: backticks are MySQL, double quotes standard SQL.

Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.

Frequently asked questions