JSON Formatter
Pretty-print and validate JSON, with the exact line and column of any error.
Lay out a query so its structure is readable.
SQL Formatter takes a query written as one long line and lays it out so you can see what it does. Major clauses start on their own lines, join conditions line up under their joins, lists of columns are broken sensibly, and subqueries are indented inside their parentheses.
Keyword case is normalised to whichever convention you prefer, with uppercase keywords against lowercase identifiers being the most common choice because it makes the structure of a query visible at a glance. String literals, quoted identifiers and comments are detected and passed through exactly as written.
This is a layout tool rather than a parser, which means it handles dialect differences gracefully and never refuses to format something it has not seen. It will not validate your query or tell you whether it will run; it will make a four-hundred-character line into something a person can read, which is usually the problem at hand.
The sql formatter is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:
The formatter works at the token level and recognises the keywords common to standard SQL plus the widely used extensions, so queries for PostgreSQL, MySQL, SQL Server, SQLite and others all format sensibly. It does not enforce any dialect's rules.
No. Only whitespace and keyword case change. Identifiers, literals and the order of everything are untouched, so the query executes identically.
It is the long-standing convention, and it works: uppercase keywords against lowercase table and column names make the shape of a query visible without reading it word by word. The option exists if your team prefers otherwise.
Yes. Quoted strings and quoted identifiers are detected and passed through byte for byte, including ones containing keywords or semicolons.
No. It formats text. Whether the query is correct, or safe to run, is a question only your database can answer.
No. Formatting happens in your browser, which matters because queries routinely contain table names and values you would not send to a third party.
If the sql formatter is not quite what you need, these other free tools solve closely related problems.
Pretty-print and validate JSON, with the exact line and column of any error.
View CSV data as a proper table you can sort, search and page through.
Pretty-print XML with proper indentation, and catch malformed documents.
Format JavaScript with consistent indentation, spacing and statement breaks.
Turn spreadsheet data into JSON, or JSON records back into CSV rows.