Oracle SQL formatter
Format Oracle SQL in your browser. Alternative-quoted strings, bind variables, database links and SQL*Plus slash lines are read the way Oracle reads them.
Every layout setting of the formatter, grouped like Editor › Formatting in the SQLly app. The style above is the starting point; anything you change here is marked.
Drop a .sql file here to open it. It is read in your browser, not uploaded.
SELECT
e.employee_id,
e.last_name,
d.department_name,
q'[O'Brien's team]' AS note
FROM
employees e
JOIN departments@hq d ON d.department_id = e.department_id
WHERE
e.hire_date >= ADD_MONTHS(TRUNC(sysdate), -12)
AND e.manager_id = :mgr
ORDER BY
e.last_name
FETCH FIRST 10 ROWS ONLY
Loading the formatter…
Shortcuts in the editor: Ctrl+Enter formats and Ctrl+Shift+Enter minifies (⌘ instead of Ctrl on a Mac). Your settings are remembered in this browser and kept in the page address, so a link shares your style – never your SQL.
What the formatter does with Oracle SQL
- Oracle strings.
q'[O'Brien's team]'alternative quoting andN'…'national strings are single literals, so the quote inside never confuses the formatter. - Binds and named arguments.
:mgrbind variables and=>named notation are kept as written. - Links and attributes stay attached.
departments@hqdatabase links and%TYPE,%ROWTYPEandSQL%ROWCOUNTattributes are never spaced apart. - Slash lines stay on their own line. The
/that ends a PL/SQL block in a SQL*Plus or SQLcl script keeps its own line, and Minify keeps it there too. - Oracle keywords get your casing, including
FETCH FIRST … ROWS ONLY,CONNECT BY,START WITHandPRIOR. - Case-safe quoting. Oracle folds unquoted names to uppercase, so Remove unnecessary quotes only unquotes names that are already uppercase. Minify keeps
/*+ … */and--+optimizer hints.
Good to know
- PL/SQL blocks stay valid and the SQL statements inside them are laid out, but
IF,LOOPand other block structure is not re-indented.
Examples
Oracle before and after
select e.employee_id,e.last_name,d.department_name,q'[O'Brien's team]' as note from employees e join departments@hq d on d.department_id=e.department_id where e.hire_date>=add_months(trunc(sysdate),-12) and e.manager_id=:mgr order by e.last_name fetch first 10 rows only
SELECT
e.employee_id,
e.last_name,
d.department_name,
q'[O'Brien's team]' AS note
FROM
employees e
JOIN departments@hq d ON d.department_id = e.department_id
WHERE
e.hire_date >= ADD_MONTHS(TRUNC(sysdate), -12)
AND e.manager_id = :mgr
ORDER BY
e.last_name
FETCH FIRST 10 ROWS ONLY
The output uses the Standard style with 4-space indents, exactly as the formatter above produces it. Switch the style to Compact for denser SQL or Expanded for leading commas and one item per line. The formatter docs cover the details.
Oracle formatter FAQ
Can it format PL/SQL?
It keeps PL/SQL valid and lays out the SQL statements inside a block, and %TYPE attributes and slash terminator lines stay intact. It does not re-indent IF, LOOP or other block structure.
Does it keep the / line at the end of a PL/SQL block?
Yes. A slash alone on its line is kept on its own line by both Format and Minify, so the script still runs in SQL*Plus or SQLcl.
Will it change my quoted identifiers?
Not unless you choose a Quoting option. Remove unnecessary quotes only unquotes names that are already uppercase, because Oracle uppercases unquoted names.
Is my SQL sent to a server?
No. The formatter is compiled to WebAssembly and runs inside your browser tab. Your SQL is never uploaded, logged or stored, and once the page has loaded it keeps working offline.
Can formatting break my query?
It is built not to. After formatting, SQLly checks its output token by token against your input. If anything other than whitespace and the casing you asked for would change, it gives your SQL back exactly as you wrote it and tells you why. SQL that does not parse cleanly, such as an unterminated string, is also left untouched, with the line and column of the problem.
Can I share my formatting settings with my team?
Yes. Every setting, including the advanced ones, is kept in the page address after the # sign, so copying the address or pressing Copy settings link shares your exact style. The link holds the settings only, never your SQL.
Other dialects
- Any dialect (auto-detect)
- SQL Server formatter (T-SQL)
- PostgreSQL formatter
- MySQL formatter
- SQLite formatter
- Snowflake SQL formatter
- BigQuery SQL formatter
- Redshift SQL formatter
Working with Oracle every day? See what the SQLly desktop app does for Oracle, or browse all features.
Like the formatter? Meet the rest of SQLly
A native SQL workbench for macOS, Windows and Linux with IntelliSense that knows your schema, guardrails for risky queries, and this formatter built into the editor.