Format, beautify, and minify SQL queries instantly. Pretty print with configurable indentation, keyword uppercasing, syntax highlighting, and proper subquery nesting. Supports SELECT, JOIN, subqueries, CTEs, CASE expressions, and all major SQL clauses. Free, runs entirely in your browser -- no data ever leaves your machine.
Formatted output will appear here...
Automatically places each SQL clause on its own line with proper indentation. Handles SELECT lists, JOIN chains, WHERE conditions, subqueries, and CTEs with intelligent nesting.
Color-coded output distinguishes keywords, strings, numbers, functions, and comments at a glance. Line numbers make it easy to reference specific parts of your query.
Choose between 2-space, 4-space, or tab indentation. Toggle keyword uppercasing on or off. Minify queries to a single line for production use.
All formatting happens in your browser. Your SQL queries are never sent to any server, making it completely safe for sensitive database queries and proprietary schemas.
SQL (Structured Query Language) is the standard language for managing and querying relational databases. Whether you are writing queries for PostgreSQL, MySQL, SQL Server, SQLite, or Oracle, well-formatted SQL is essential for readability, maintainability, and collaboration. Raw or compressed SQL queries can be extremely difficult to read and debug, especially when they involve multiple JOINs, subqueries, or complex WHERE clauses.
Formatting SQL queries adds proper indentation, line breaks at clause boundaries, and consistent keyword casing. This makes the logical structure of the query visible at a glance -- you can immediately see which tables are being joined, what conditions are applied, how results are grouped, and what ordering is used. Well-formatted SQL is easier to review in pull requests, debug when results are unexpected, and maintain as requirements change over time.
Paste your SQL into the input pane and click Format to beautify it with syntax highlighting and line numbers. The tool tokenizes your SQL, identifies keywords, handles string literals and comments without modification, and applies intelligent indentation rules. Click Minify to compress your query to a single line with comments stripped. Everything runs entirely in your browser -- no data is ever sent to a server.
--) and multi-line block comments (enclosed in /* */). In formatted output, comments are preserved and placed on their own lines at the appropriate indentation level. In minified output, comments are stripped entirely to produce the most compact result possible. String literals that contain comment-like syntax (e.g., 'value -- not a comment') are correctly identified as strings and left unchanged.
Check out our other free developer tools. Format JSON, parse AWS ARNs, decode JWTs, generate Kubernetes manifests, and more -- all from your browser with no sign-up required.