Data Tools
SQL Formatter
Format and beautify SQL queries. Free online tool — runs in your browser, no sign-up required.
See how to use this toolSQL Formatter
Data is converted locally in your browser without server upload.
About SQL Formatter
SQL Formatter parses your query with a tokenizer that understands SQL keywords, identifiers, string literals, numeric literals, comments (both -- and /* */), and parameter placeholders, then re-emits the query with consistent indentation and keyword capitalization. Unlike a regex-based prettifier, the tokenizer correctly handles string literals containing keywords (so 'SELECT' inside quotes is not uppercased) and quoted identifiers that contain reserved words.
The formatter supports dialect-specific rules for PostgreSQL, MySQL, SQL Server (T-SQL), SQLite, and Oracle PL/SQL — because the reserved-word list and the placement of things like LIMIT, RETURNING, and TOP differ. You choose keyword case (upper, lower, preserve), indent style (2 spaces or tabs), and whether to put each column of a SELECT list or each table of a FROM clause on its own line, which is what makes a 200-line query actually readable.
Everything runs locally in your browser. That matters because real-world queries frequently contain table names, schema details, or bind-parameter values that reveal internal structure you should not paste into an online formatter.
How to use it
- 1Paste your SQL query into the editor.
- 2Pick the SQL dialect so reserved-word recognition is correct (PostgreSQL, MySQL, T-SQL, etc.).
- 3Choose keyword case (upper / lower / preserve) and indent style.
- 4Toggle 'One clause per line' for SELECT columns, FROM tables, and AND/OR conditions.
- 5Click Format, then Copy or Download the result.
When to use it
- ✓Making a 300-line generated ORM query readable before optimizing it.
- ✓Normalizing keyword case across a legacy codebase before a code review.
- ✓Formatting a SQL migration script so the diff in version control is clean.
- ✓Prettifying a query copied from a slow log before sharing it with the DBA.
Features
- •Tokenizer-based formatting — string literals and quoted identifiers are never mangled.
- •Dialect-aware reserved-word lists for PostgreSQL, MySQL, T-SQL, SQLite, and PL/SQL.
- •Configurable keyword case, indent, and one-clause-per-line layout.
- •100% client-side — queries with internal schema details stay on your machine.
Related tools
JSON Formatter & Validator
Paste and check JSON syntax, then indent it, sort object keys, or minify the output for copying or download.
JSON to CSV
Convert JSON data to CSV format. Free online tool — runs in your browser, no sign-up required.
CSV to JSON
Paste delimited rows and export a JSON array. Set the separator, choose whether the first row is a header, and control type inference.
XML Formatter
Format and beautify XML data. Free online tool — runs in your browser, no sign-up required.
YAML Validator
Validate and format YAML data. Free online tool — runs in your browser, no sign-up required.
Regex Tester
Test regular expressions with real-time matching. Free online tool — runs in your browser, no sign-up required.
Unix Timestamp Converter
Convert between Unix timestamps and human-readable dates. Free online tool — runs in your browser, no sign-up required.
JSON Diff
Compare two JSON files and find differences. Free online tool — runs in your browser, no sign-up required.
FAQ
Does it validate that my SQL is syntactically correct?
It tokenizes and reformats, and will flag unterminated string literals or unclosed comments, but it does not do full grammar validation — that requires a dialect-specific parser tied to a real engine. Think of it as a formatter with light error detection, not a linter.
Why are keywords inside my string literal not uppercased?
Because the tokenizer knows it is inside a string literal, not a keyword. Regex-based formatters get this wrong; a real tokenizer does not.
Which dialects are supported?
PostgreSQL, MySQL, SQL Server (T-SQL), SQLite, and Oracle PL/SQL. Each uses the correct reserved-word list and clause placement (e.g. LIMIT vs TOP vs FETCH FIRST).
Is my SQL uploaded anywhere?
No. Tokenizing and formatting run entirely in your browser. Queries containing internal table names, schema details, or bind parameters never leave your machine.
Does it handle comments?
Yes. Both line comments (--) and block comments (/* */) are preserved and indented to match the surrounding code. Inline comments stay on their line.
Can it minify SQL?
Yes. Toggle 'Minify' to collapse whitespace and newlines into a single line, which is useful for stuffing a query into a URL parameter or a single-line config field.