Code Beautifier for SQL and PL/SQL
Format, Beautify and Minify SQL Online. Supports standard SQL, PostgreSQL & MySQL with auto upper case for keywords.
Come utilizzare SQL Formatter
Incolla la query SQL
Copia la tua query SQL non formattata o compressa nel pannello "Input SQL". Puoi usare il pulsante con l'icona del codice per caricare una query di esempio con JOIN, GROUP BY e HAVING.
Scegli il dialetto SQL
Seleziona il dialetto del tuo database dal menu "Dialetto": Standard SQL per compatibilità generica, PostgreSQL per feature come ILIKE, RETURNING e JSONB, oppure MySQL per AUTO_INCREMENT, ENUM e tipi specifici.
Seleziona la modalità
Clicca la scheda "Formatta" per ottenere SQL leggibile con clausole su righe separate e indentazione, oppure "Minifica" per ridurre la query a una singola riga compatta.
Configura le opzioni
In modalità Formatta puoi scegliere l'indentazione (2 o 4 spazi). Attiva "Uppercase keywords" per convertire automaticamente SELECT, FROM, WHERE e tutte le altre keyword in maiuscolo.
Elabora e copia il risultato
Clicca "Formatta" o "Minifica". La barra delle statistiche mostra il numero di keyword, le tabelle referenziate e il numero di righe. Usa il pulsante di copia per copiare l'output negli appunti.
Suggerimenti
- Usa il formattatore prima di incollare query in una pull request o in documentazione: SQL ben indentato con clausole su righe separate è molto più facile da revisionare per i colleghi.
- Se lavori con PostgreSQL, seleziona il dialetto "PostgreSQL" per riconoscere correttamente keyword come ILIKE, RETURNING e LATERAL che non fanno parte dello Standard SQL.
- Combina "Uppercase keywords" e "Formatta 4 spazi" per ottenere query nel formato standard di molti style guide aziendali e strumenti di linting SQL come sqlfluff.
Domande frequenti
How can I format a free SQL query online?
Attach your query to the "Input SQL" area, select the correct dialect (Standard, PostgreSQL or MySQL), choose the Format mode and click the button. The query will be indented with separate clauses on distinct lines.
What is the difference between standard SQL dialects, PostgreSQL, and MySQL?
Standard SQL recognizes common ANSI keywords for all databases. PostgreSQL adds keywords like ILIKE, RETURNING, LATERAL and JSONB support. MySQL adds features such as AUTO_INCREMENT, ENGINE, ENUM, and types like TINYTEXT and MEDIUMINT.
What is the point of SQL miniaturization?
Minification removes unnecessary comments and whitespace, condensing the query into a single line. It's useful for reducing query sizes embedded in configurations, JSON files, or source code where space is limited.
Why does it make sense to use SQL keywords in uppercase?
Write SELECT, FROM, WHERE in uppercase is a widely accepted convention that improves readability, immediately distinguishes keywords from column and table identifiers, and facilitates code review in teams.
Does the SQL formatter change content between apostrophes?
No. The formatter's tokenizer recognizes string literals bounded by single quotes and leaves them unchanged. The "Uppercase keywords" option does not apply to the text content of strings, preserving their original value.
Want to learn more?
Read our in-depth articles on related topics: