SQL Formatter
Format and indent SQL code into a clean, readable structure directly in your browser.
This tool runs entirely in your browser. Your files are never uploaded to a server.
SELECT id,name
FROM users
WHERE active=true
ORDER BY name;What this formatter does
Scans for a fixed set of SQL keywords — SELECT, FROM, WHERE, the JOIN variants, GROUP BY, ORDER BY, HAVING, LIMIT, OFFSET, UNION [ALL], INSERT INTO, VALUES, UPDATE, SET, DELETE FROM, AND, and OR — and puts each on its own line, matching them case-insensitively and uppercasing them in the output. AND, OR, SET and VALUES are indented two spaces to sit under their clause.
How to use it
Paste a SQL statement into the editor and the formatted result updates immediately. Copy the result when ready, or use Reset to clear the editor; Reset does not restore the original sample.
Formatting behavior
Text inside single- or double-quoted string literals is left untouched, so a keyword that happens to appear inside a quoted value is never split onto its own line. Everything else is scanned for the recognized keyword list; runs of blank lines collapse and trailing whitespace before a line break is trimmed.
Important parser limitation
This is a keyword-spotting text formatter, not a SQL parser, validator, or dialect-aware pretty-printer. It only recognizes the fixed keyword list above — CTEs (WITH), CASE/WHEN, window functions, subqueries, and dialect-specific syntax (T-SQL, PL/pgSQL, etc.) are not specially formatted and pass through as plain text. It doesn't validate that the SQL is syntactically correct, and it doesn't know about column names or table structure.
Safe review workflow
Because formatting is purely keyword-based, review the output before running it, especially for complex queries with nested subqueries or nonstandard syntax where the line breaks may not match how you'd normally structure the query. Keep the original alongside the formatted version.
Example
Pasting `select id, name from users where active = true and role = 'admin'` produces `SELECT id, name`, `FROM users`, `WHERE active = true`, and an indented ` AND role = 'admin'` on its own line, each keyword uppercased and moved to the start of a new line.
Privacy
Processing happens locally in your browser. The pasted SQL is not uploaded by this tool.
Frequently Asked Questions
- What does the SQL Formatter do?
- Format and indent SQL code into a clean, readable structure directly in your browser.
- Does this SQL tool change program behavior?
- It only changes layout or removable whitespace. Review minified output before production use when code relies on unusual syntax.
- Is my code uploaded?
- Processing is local and your code is never uploaded.
Related Tools
XML Formatter
Format and indent XML code into a clean, readable structure directly in your browser.
Markdown Formatter
Format and indent Markdown code into a clean, readable structure directly in your browser.
YAML Formatter
Format and prettify YAML documents instantly in your browser.
CSS Formatter
Format and indent CSS code into a clean, readable structure directly in your browser.
Excel to SQL Insert Generator
Convert Excel or CSV rows into ready-to-run SQL INSERT statements for free.
GraphQL Formatter
Format and indent GraphQL code into a clean, readable structure directly in your browser.