Oracle SQL Formatter
Format Oracle SQL and PL/SQL in your browser. Handles MERGE, PL/SQL blocks, hints, bind variables, and comments.
About this tool
Copy-pasted Oracle SQL often arrives without line breaks, with inconsistent indentation, or with SELECT lists that wrap awkwardly at the terminal width. This tool normalises all that — consistent indent, keywords upper or lower-cased as you prefer, and clauses on predictable lines.
The PL/SQL dialect is used, which understands the full Oracle surface area: BEGIN/END blocks, cursor loops, exception handlers, MERGE statements, CONNECT BY hierarchical queries, and hints. The formatter preserves comments verbatim, including header banners and inline hints — it will not move a hint away from its statement.
Bind variables (:var_name) and substitution variables
(&var) are recognised as identifiers and left
untouched, so formatter output drops cleanly back into SQL*Plus, a
DB client, or a PL/SQL package body.
Frequently asked questions
Does this format PL/SQL, not just SQL?
Yes. The formatter uses the PL/SQL dialect of sql-formatter and handles BEGIN/END/EXCEPTION blocks, LOOP/IF/CASE control flow, cursors, and package bodies.
Are Oracle hints preserved?
Yes. Comments including hint comments like /*+ INDEX(t idx_emp_name) */ are preserved in place. Bind variables (:var_name) are treated as identifiers and left alone.
Will this rewrite my comments?
No. Both line comments (--) and block comments (/* */) are preserved, including any ASCII-art section headers you may have.
How does it handle MERGE statements?
The formatter recognises MERGE INTO … USING … ON (...) WHEN MATCHED THEN UPDATE SET … WHEN NOT MATCHED THEN INSERT … as a single statement and indents the clauses consistently.
Is my SQL sent to your servers?
No. Formatting runs in your browser via the sql-formatter library.