The Paper Room

SQL Formatter

Paste any SQL query and get it back cleanly formatted with proper indentation, line breaks, and keyword casing. The formatter supports four SQL dialects — Standard SQL, PostgreSQL, MySQL, and SQLite — so keyword handling and function recognition match your target database.

This is especially useful for debugging long queries copied from logs or ORM output, reviewing pull requests with inline SQL, or cleaning up ad-hoc queries before saving them to a shared repository. The formatter uses the sql-formatter library under the hood, which handles subqueries, CTEs, JOIN chains, and other complex constructs correctly.

Everything runs in your browser — your queries are never sent to a server.

By The Paper Room Editorial TeamDeveloper Tools

Frequently asked questions

Which SQL dialects are supported?

Standard SQL, PostgreSQL, MySQL, and SQLite. The dialect selector adjusts keyword recognition and formatting rules — for example, PostgreSQL-specific operators and MySQL's backtick quoting are handled correctly when the right dialect is selected.

Does this validate my SQL?

No — this is a formatter, not a validator or parser. It reformats the text structure of your query for readability but does not check whether the query is syntactically correct or would run against your database.

Can it handle CTEs and subqueries?

Yes. The sql-formatter library correctly handles WITH clauses (CTEs), nested subqueries, CASE expressions, and multi-level JOIN chains, indenting each level appropriately.