DeveloperKit

SQL Formatter

Turn long, one-line SQL queries and ORM logs into clean, indented, syntax-highlighted SQL, or minify them. Free, private, and 100% in your browser.

Input SQL

1 lines · 0 B

Output

Formatted SQL will appear here.

Format SQL Queries Online

Queries copied from application logs, ORMs, and monitoring tools usually arrive as one very long line. The formatter breaks them into clauses, indents subqueries and CASE expressions, and lists columns and conditions one per line, so you can see what the query actually does.

Before and after
select id, email from users where active = 1 and created_at > ? order by id

SELECT
  id,
  email
FROM
  users
WHERE
  active = 1
  AND created_at > ?
ORDER BY
  id

Features

  • Readable layout

    Each clause (SELECT, FROM, WHERE, GROUP BY…) starts a new line, columns and conditions are listed one per line, and subqueries, CASE expressions, and long column lists are indented.

  • Syntax highlighting

    Keywords, functions, strings, numbers, placeholders, and comments are colored so you can scan the query at a glance.

  • Many dialects

    PostgreSQL ($1, ::casts, JSON operators, $$ bodies), MySQL (backticks, ON DUPLICATE KEY UPDATE), SQL Server ([brackets], @params), and SQLite.

  • Keyword casing

    Uppercase, lowercase, or keep keywords as written. Identifiers, strings, and comments are never changed.

  • Catches syntax errors

    Unclosed strings, quoted identifiers, comments, and unbalanced parentheses are reported with the exact line and column.

  • Private by design

    Queries are formatted in your browser and never uploaded, so table names and data in your logs stay private.

How to Format SQL

  1. Paste your SQL query or upload a .sql file.
  2. Choose Beautify or Minify, the indentation, and the keyword case.
  3. Fix any error shown with its line and column.
  4. Copy or download the formatted SQL.

Frequently Asked Questions

Which SQL dialects are supported?

The formatter understands standard SQL plus the syntax of PostgreSQL, MySQL and MariaDB, SQL Server (T-SQL), SQLite, and most cloud warehouses. Dialect-specific features like quoted identifiers, placeholders, casts, and dollar-quoted strings are kept exactly as written.

Can I format SQL from ORM logs (Hibernate, Sequelize, Prisma, Django)?

Yes. That is what the tool is made for: ORMs log each query as a single long line. Paste it, and placeholders such as ?, $1, :name, and @p0 are kept and highlighted.

Does formatting change what my query does?

No. Only whitespace and, if you choose, the case of keywords change. Identifiers, string literals, numbers, and comments are left untouched. Minify removes comments.

Does the formatter validate my SQL?

It checks the syntax it needs to format safely: strings, quoted identifiers, comments, and parentheses must be closed. It does not check table or column names or the full grammar of every database.

  • GraphQL Formatter

    Format and validate GraphQL queries, mutations, fragments, and schemas (SDL) with syntax highlighting.

  • Markdown Editor & Previewer

    Write Markdown with a live GitHub-style preview: tables, task lists, code blocks, and alerts. Ideal for README files.

  • JSON Formatter

    Beautify, minify, and validate JSON instantly with exact line and column error reporting.

  • JSON Comparer

    Compare two JSON documents side by side and see every added, removed, and changed value.