SQL Formatter
Format SQL for readability while keeping string literals, quoted identifiers, escapes and comment boundaries intact.
About This Tool
ToolsFaction SQL Formatter uses a tokenizer that separates string literals, quoted identifiers, comments, words, numbers, operators and punctuation before formatting. Keyword casing, line breaks and spacing are applied only to SQL syntax tokens. Literal text and escaped quotes remain unchanged, while line comments keep their original statement boundary. The tool formats SQL locally in your browser and does not execute queries or connect to a database.
How to Use
- Paste a SQL query into the source editor.
- Choose Format SQL.
- Review the formatted query and confirm that its literals and identifiers remain unchanged.
- Copy the result when ready.
Example
Formatting SELECT 'hello world' AS message; keeps both spaces inside the string literal while presenting SQL keywords consistently.
Frequently Asked Questions
Does the formatter change text inside SQL strings?
No. Single-quoted string literals are tokenized separately and their content is preserved.
Are escaped single quotes supported?
Yes. SQL-style doubled quotes such as 'It''s working' remain unchanged.
What happens to quoted identifiers?
Double-quoted, backtick-quoted and bracketed identifiers are protected from keyword and whitespace formatting.
Are SQL comments preserved?
Yes. Line comments keep their line boundary and block comments remain separate tokens.
Does this tool execute SQL?
No. It only formats text in your browser and does not connect to a database.