SQL formatter
Reformat PostgreSQL-style SQL with line breaks, spacing and optional uppercase keywords.
- 1Add input
- 2Adjust settings
- 3Get your result
Tool input and files are processed in this browser without being uploaded.
Before you start
Make PostgreSQL-style query text easier to read. You can uppercase the keywords this tool recognizes or leave their case as typed. Formatting happens in your browser without connecting to a database or running the SQL.
How to use this tool
- Paste a query into “SQL input” or choose one local UTF-8 file. Clear the text box to use the file, or remove the file to use pasted SQL alone.
- Under “Options”, choose whether to enable “Uppercase recognized keywords”, then select “Format SQL”.
- Compare the result with the original, especially numbers and operators. Use “Copy result” to copy the text or “Download” to save formatted.sql. Run the formatter again after changing the input or option.
Supported inputs and limits
Paste up to 1 MiB of UTF-8 text or choose one UTF-8 .sql or .txt file up to 10 MiB. Filenames can contain up to 512 UTF-16 code units; a visible character may use more than one code unit. Nonempty pasted text takes priority, including text that contains only spaces, but a selected file is still checked and read. Block comments can nest up to 100 levels.
Worked example
Example input
select 'a b', 1.25 from t where x=2;
Example options
{}Example output
SELECT 'a b', 1.25 FROM t WHERE x = 2;
When something does not work
Check quotes, comments and matching parentheses or brackets if formatting fails. For a file error, save a UTF-8 copy in another application and select it again, or remove the file and paste the SQL. Reduce oversized input or shorten a long filename. Use another formatter for unsupported syntax. After changing the input or cancelling a run, select “Format SQL” to try again.
Frequently asked questions
Are my files uploaded?
No. Your SQL and files are processed in your browser. A recent workspace may remain in memory when you visit other tools in the same tab, subject to size and time limits. Refreshing or closing the tab clears it. Download any result you want to keep.
Does this check all PostgreSQL syntax?
No. It can reject unclosed quotes or comments and mismatched brackets, but a successful result does not prove the SQL is valid. It does not check tables, columns or query behavior. It can format array slices such as a[1:2] and preserve recognized numeric spellings such as 1_000 or 0xFF. The content of recognized dollar-quoted bodies stays unchanged.
Documentation & further reading
Related tools
JSON formatter and string tools
Format or minify JSON, sort object keys, or convert between plain text and a JSON string.
JavaScript regex tester
Test JavaScript patterns against text and inspect matches, positions and capture groups.
Compare text
Compare two texts line by line, with a side-by-side view of changes.
HTML formatter
Format HTML source with consistent indentation and review the result as text.