FormatPaste

SQL Formatter

Paste SQL queries, format them instantly, and copy readable output.

Ready
All formatters

Input

Don't paste secrets · formatting is not stored

Output

formatted

Free SQL formatter

Format SQL queries online without opening an editor

Use this SQL formatter for one-line database queries, copied SELECT statements, joins, WHERE clauses, inserts, updates, and snippets from logs or admin tools. Paste SQL on the left and copy formatted SQL from the right.

Format SQL queries

Turn compact SELECT, INSERT, UPDATE, DELETE, JOIN, WHERE, and ORDER BY statements into readable SQL.

Clean copied database snippets

Remove paste artifacts and make query output easier to scan before sharing or debugging.

Copy-ready SQL

Skip the editor round-trip: paste SQL, review formatted output, and copy it back.

How this SQL formatter helps

Before and after formatting

Paste compact, copied, or hard-to-read SQL into the input pane. FormatPaste cleans common paste artifacts first, then formats the code into readable output that is easier to scan, debug, share, or copy into your editor.

Common SQL formatting use cases

Use it for quick snippets from documentation, AI chat output, Stack Overflow answers, config examples, API responses, old files, minified blocks, and code that picked up line numbers or markdown fences while being copied.

Safe paste reminder

FormatPaste is built for speed, but you should avoid pasting passwords, API keys, tokens, private keys, recovery codes, customer data, or other secrets into any online formatter. Use local tools for sensitive code.

SQL formatting example

Before
select u.id, u.email, count(o.id) as orders from users u left join orders o on o.user_id = u.id where u.active = true group by u.id, u.email order by orders desc limit 10;
After
SELECT u.id, u.email, count(o.id) AS orders
FROM
  users AS u
  LEFT JOIN orders AS o ON o.user_id = u.id
WHERE u.active = TRUE
GROUP BY u.id, u.email
ORDER BY orders DESC
LIMIT 10;

When to use a SQL formatter

Read one-line queries from logs

ORMs, query logs, and monitoring tools often print SQL as a single line. Formatting puts each clause on its own line so you can see which tables are joined, what is filtered, and how results are grouped.

Review joins and filters faster

Each JOIN gets its own indented line with its ON condition, so a missing join condition or a filter in the wrong place is much easier to spot during code review or when debugging slow queries.

Consistent SQL style for teams

Uppercase keywords, explicit aliases, and one clause per line give every query the same shape. Paste the formatted query into pull requests, tickets, or documentation and it reads the same for everyone.

PostgreSQL-first parsing

The formatter uses a PostgreSQL grammar, which covers the standard SQL used by most databases. If a vendor-specific query fails to parse, remove the non-standard part or format that section by hand.

SQL Formatter FAQ

How do I format SQL online?

Paste SQL into the input pane. FormatPaste formats the query automatically and shows copy-ready SQL output.

Can it format one-line SQL queries?

Yes. Paste a compact one-line query and it will be expanded into a more readable structure.

What SQL style is supported?

The formatter is useful for common SQL queries, especially PostgreSQL-style syntax and general SELECT, INSERT, UPDATE, and DELETE statements.

Is this SQL formatter free?

Yes. It is free for quick SQL formatting.

Does the SQL formatter uppercase keywords?

Yes. Keywords such as SELECT, FROM, WHERE, JOIN, GROUP BY, and ORDER BY are written in uppercase so they stand out from table and column names.

Can it format MySQL or SQL Server queries?

Queries are parsed with a PostgreSQL grammar. Standard SELECT, INSERT, UPDATE, DELETE, and JOIN syntax shared by MySQL, SQLite, and SQL Server usually formats fine; vendor-specific syntax such as backtick identifiers or T-SQL extensions may return a parse error.

Why did the formatter add AS to my aliases?

Table aliases like "users u" are written as "users AS u". The query means exactly the same thing; the explicit AS just makes aliases easier to spot when reading long joins.