SQL formatter & beautifier

Format any SQL query

Paste a compressed or messy SQL query — SELECT, INSERT, CREATE TABLE, stored procedures — and get clean, readable output instantly.

Browser-side only — nothing sent to a server
Dialect
Indent
Keywords
Line width
Input — paste SQL here
Output — formatted SQL
Formatted output will appear here.

What is sqlchop?

sqlchop is a free, browser-side SQL formatter. Paste any SQL query — a SELECT with ten joins, a CREATE TABLE statement, a stored procedure, or a one-liner you copied from a log file — and sqlchop reformats it with consistent indentation, clean line breaks, and normalized keyword casing.

SQL queries arrive messy in the real world. ORM-generated SQL is often emitted as a single line. Database logs compress queries to save space. Code copied from Stack Overflow uses inconsistent spacing. sqlchop fixes all of this in under a second, entirely in your browser using the sql-formatter JavaScript library.

Choose your database dialect (PostgreSQL, MySQL, SQL Server, BigQuery, SQLite, or others) for accurate keyword handling. Configure indent size (2 spaces, 4 spaces, or tabs) and keyword casing (UPPERCASE or lowercase) to match your team's style guide. The formatted output can be copied to clipboard or downloaded as a .sql file.

Nothing is uploaded. Your SQL query is processed on your device and never leaves your browser. You can use sqlchop on a sensitive query — production credentials embedded in a connection string, proprietary schema names — without concern.

When to use a SQL formatter

The most common trigger is debugging. When a query runs slow or returns unexpected results, the first step is reading it clearly. A 400-character one-liner is impossible to reason about. Formatted over 40 lines, the missing WHERE clause or wrong JOIN condition jumps out immediately.

Code review is the second common trigger. Unformatted SQL in a pull request is a smell — it signals the author didn't read their own query carefully. Consistent formatting makes reviewing SQL as fast as reviewing application code.

The third trigger is BI tool exports. Tools like Tableau, Metabase, Looker, and dbt generate SQL that is technically correct but formatted for the machine, not the reader. sqlchop makes it reader-friendly instantly.

Frequently asked questions

Is my SQL sent to a server?

No. sqlchop uses sql-formatter, a JavaScript library that runs entirely in your browser. Your SQL query is processed on your device and never transmitted anywhere. You can disconnect from the internet after the page loads — the tool still works.

Which SQL dialects does sqlchop support?

PostgreSQL, MySQL, SQL Server (T-SQL), BigQuery, SQLite, PL/SQL (Oracle), Spark SQL, Redshift, Trino/Presto, and Hive. Select the dialect from the dropdown before formatting to get dialect-specific keyword handling and function casing.

Why format SQL queries?

SQL queries copied from logs, ORMs, or BI tools often arrive as a single compressed line with no indentation. Formatted SQL is dramatically easier to read, debug, and share in code reviews. Consistent formatting also makes it easier to spot mistakes like missing WHERE clauses or incorrect JOIN conditions.

Can sqlchop format stored procedures?

Yes. sqlchop handles CREATE PROCEDURE and complex multi-statement SQL blocks. For best results with T-SQL stored procedures, select the SQL Server dialect.

What does uppercase keywords mean?

The Keywords option controls whether SQL keywords like SELECT, FROM, WHERE, JOIN, and GROUP BY are uppercased or lowercased in the output. This is a style preference — both are valid SQL. Most style guides recommend uppercase keywords to distinguish them from table and column names.

How do I format a query from my ORM?

Enable query logging in your ORM (e.g. RAILS_LOG_LEVEL=debug for Rails, SQL_LOG=true for Django, or echo: true in Sequelize), copy the logged query, paste it into sqlchop, select your database dialect, and click Format. The output will have clean indentation and readable line breaks.

Does sqlchop modify my query logic?

No. sqlchop is a formatter, not a query optimizer or rewriter. It adds whitespace and normalizes casing but does not change the query's meaning, add indexes, reorder clauses, or transform the SQL in any semantically significant way. What goes in is logically identical to what comes out.

Can I use sqlchop as an API?

sqlchop currently runs browser-side only. An MCP tool that exposes format_sql(query, dialect) is planned for the paid tier. If you need programmatic SQL formatting today, the sql-formatter npm package is the underlying library — install it directly in your project with npm install sql-formatter.