SQL Formatter
Beautify SQL with consistent indentation and keyword casing, or minify it onto one line. Supports MySQL, PostgreSQL, SQLite, SQL Server, BigQuery, Snowflake and Oracle.
Input
Result
How to use
Paste a query on the left and the formatted version appears on the right. Pick the dialect that matches your database first: the parser needs it to tell a MySQL backtick identifier from a PostgreSQL cast or a T-SQL bracket, and choosing the wrong one is the usual reason a valid query is reported as a syntax error.
Keyword case can be upper, lower or left as written. Indentation is two spaces, four spaces or a tab, and the blank-line setting controls how far apart consecutive statements sit when you paste a whole script. The output is meant to be readable, not to change what the query does; comments are kept where they were.
Minify does the opposite. It removes comments and collapses every run of whitespace outside string literals and quoted identifiers into a single space, and drops spaces around parentheses and commas. Use it when a query has to fit into a log line, an environment variable or a JSON field. Because it does not parse the SQL, it also works on dialect extensions the formatter does not understand.
Queries never leave your browser, so it is fine to format SQL that contains table names, literals or customer data from a production system.
Tools people use next
JSON Formatter
Indent JSON so you can read it, or squeeze it onto one line. Syntax errors are reported with the line they are on.
JSON ↔ CSV Converter
Turn a JSON array into CSV, or a CSV back into JSON. Choose the delimiter and say whether the first row holds column names.
Table Converter
Turn a table copied out of a spreadsheet into Markdown, HTML, or CSV. Paste it and all three come out at once.
YAML ⇄ JSON Converter
Convert YAML to JSON and JSON to YAML in your browser. Auto-detects the input, handles multi-document YAML, and reports syntax errors with the line number.