SQL Formatter
Format SQL for MySQL, PostgreSQL, SQLite and more — dialect, indent and keyword case.
Last updated:
Tool
No SQL yet
No SQL yet
Your files never leave your device - processing happens in your browser.
Related tools: JSON Formatter · XML Formatter · YAML Formatter
A SQL formatter is a tool that takes SQL written on one line or with messy spacing and rewrites it with clean, consistent indentation — one clause per line, nested parts indented. FreeToolsKit's SQL formatter supports Standard SQL, MySQL, PostgreSQL, SQLite and five more dialects, with 2-space, 4-space or tab indentation and uppercase, lowercase or unchanged keywords. Everything runs in your browser, so your SQL is never uploaded.
How do you format SQL?
- Paste your SQL into the box — or press Sample to load an example query.
- Pick a dialect — Standard SQL, MySQL, PostgreSQL, SQLite and six more — with the Dialect menu above the SQL box.
- Pick an indent — 2 spaces, 4 spaces or Tab — and a keyword case — Upper, lower or Preserve.
- Press Format to tidy the SQL, or Minify to collapse it to one line.
- Press Copy to take the SQL, or Download .sql to save it as a query.sql file.
- Press Reset to clear the box, or Upload .sql to format a SQL file instead of pasting.
What is the SQL Formatter used for?
- Tidying a query copied from a log file or a chat message before running it.
- Making a long JOIN readable before adding a WHERE condition.
- Minifying a query before pasting it into code or a migration file.
- Checking a pasted query for a syntax error before running it against a database.
- Rewriting a query in a consistent style before sharing it with a team.
Frequently asked questions
Is the SQL formatter free?
Yes. The tool is completely free with no sign-up and no usage cap. Format as much SQL as you like, as often as you like.
Is my SQL uploaded anywhere?
No. Formatting and validation happen in your browser tab. Your SQL stays on your device — nothing is uploaded, logged or stored.
What does Format change, and what does Minify do?
Format re-indents the SQL — one clause per line, nested parts indented — and sets keyword case the way you chose. It keeps comments and the exact contents of string literals. Minify goes further: it collapses the query to one line and removes comments, while string contents stay byte-for-byte the same.
What errors does the validator catch?
Syntax problems the parser reports — an unterminated string or an unclosed parenthesis, for example — each with line and column. It does not check whether the SQL would run: a WHERE with no condition or a wrong table name still formats, because the formatter only needs the text to parse.
What are the limits?
SQL is limited to 100,000 characters — longer input shows an error and the Format and Minify buttons stay disabled until it is shortened. With an empty box the tool shows “No SQL yet”. You can also upload a .sql file instead of pasting.
Related tools
- JSON FormatterValidate, pretty-print and minify JSON with precise error pinpointing.
- XML FormatterFormat, validate and minify XML — 2, 4 or tab indent, with line-and-column errors.
- YAML FormatterFormat, validate and minify YAML — 2- or 4-space indent, flow-style minify, line errors.
- CSS FormatterFormat, validate and minify CSS — 2, 4 or tab indent, with line-and-column errors.
- HTML FormatterFormat, validate and minify HTML — 2, 4 or tab indent, with line-and-column errors.
- Diff CheckerCompare two texts line by line — added, removed and unchanged lines, in your browser.
Last updated:
- Free forever
- Files stay on your device
- No sign-up