Text and dataRuns in your browser

SQL Formatter for Readable Queries

Turn SQL into a consistent, reviewable layout while preserving quoted values and comments, with no database connection.

  • Runs locally
  • No query execution
  • Size and nesting limits
Online tool

Try the tool

Add your data, choose the settings, and get the result.

SQL query

Formatted query

—

Standard / PostgreSQL / SQL Server mode treats backslashes in ordinary strings literally and supports nested /* ... */ comments. MySQL mode enables backslash string escapes and ends a block comment at the first */. The formatter preserves strings, comments, and quoted identifiers; it does not perform semantic validation or execute SQL.

Processing in your browser

Text and selected files are processed in the current browser and are not sent to a server to produce the result.

Reviewed: 2026-07-17
01

How to use it

  1. 1

    Paste SQL and choose the keyword casing.

  2. 2

    Choose two- or four-space indentation and run the formatter.

  3. 3

    Review any dialect warnings and copy the result.

02

What the tool can do

  • Common SELECT, INSERT, UPDATE, DELETE, WITH, UNION, JOIN, ordering, and grouping clauses.
  • Strings with escaped quotes, line and block comments, and quoted identifiers.
  • Nested subqueries with a depth limit and indentation.
  • Uppercase, lowercase, or preserved keyword casing.
03

Common use cases

  • Preparing a query for code review.
  • Reading SQL copied from logs or migrations.
  • Normalizing an example for documentation or an issue.
04

How it works inside

Input is limited to 500,000 characters, 20,000 tokens, and depth 64.

The formatter does not connect to a database or send SQL to the WebDiag backend.

05

Questions and answers

Does formatting SQL change database data?

No. The query is handled as text in the browser and is not executed. The tool adds indentation and line breaks for readability. No database connection is required.

Does an error-free result mean the query will run?

Formatting does not check tables, permissions, or every rule of your database engine. Choose the appropriate dialect and test the query in a safe project environment. Execution requires separate database access.