SQL

Oracle SQL Formatter

Format Oracle SQL and PL/SQL, including anonymous blocks, hierarchical queries and legacy joins.

Private by design — your data never leaves your device.
✓ Free forever✓ No sign-up✓ No ads✓ Works offline once loaded

Oracle SQL Formatter

Format Oracle SQL and PL/SQL, including anonymous blocks, hierarchical queries and legacy joins.

Input

Your Oracle SQL

Nothing is uploaded.

Output

Formatted Oracle SQL

Your result appears herePaste on the left and select “Format Oracle SQL”

Oracle codebases carry decades of accumulated syntax. A single package can contain a modern MERGE written last year, a hierarchical CONNECT BY query from the nineties, and a join expressed with the (+) operator that predates ANSI join syntax in Oracle entirely. All of it still runs, and all of it has to be readable.

With the PL/SQL dialect selected, this formatter parses the Oracle-specific constructs a generic SQL parser rejects outright: DECLARE … BEGIN … END; blocks, the bare / that terminates them in SQL*Plus, START WITH and CONNECT BY PRIOR, the (+) outer join marker, and DUAL.

How it works

How to use the oracle formatter

  1. 1

    Paste the query, block or script

    A single SELECT, an anonymous PL/SQL block, or a script mixing both. Slash terminators are recognised and kept on their own lines.

  2. 2

    Set indentation and keyword case

    Upper-cased keywords is the long-standing Oracle convention and matches what SQL Developer produces, which keeps diffs against existing code small.

  3. 3

    Copy into SQL Developer, SQL*Plus or your repository

    Plain text output, ready to paste into a worksheet or a versioned .sql file.

Oracle-specific syntax this handles

  • DECLARE … BEGIN … END;. Anonymous blocks are recognised, with DECLARE, BEGIN and END; as their own lines and the SQL statements inside them formatted normally.
  • The / terminator. Kept on its own line. It is not part of the PL/SQL language — it is the SQL*Plus instruction meaning "execute the buffer", which is why a block needs both a closing END; and a following slash while an ordinary SELECT needs only a semicolon.
  • CONNECT BY hierarchies. START WITH, CONNECT BY PRIOR and ORDER SIBLINGS BY each get a top-level line, and LEVEL is recognised as the pseudocolumn it is. Hierarchical queries are exactly the case where clause-per-line layout makes the recursion direction obvious.
  • The (+) outer join operator. Preserved on the side of the predicate where you wrote it, which is the side that gets the nulls padded — a detail worth being able to see at a glance, since it is the reverse of how LEFT JOIN reads.
  • MERGE. The USING subquery, the parenthesised ON predicate that Oracle requires, and the WHEN MATCHED / WHEN NOT MATCHED branches are each broken out.
  • DUAL. The one-row, one-column system table used whenever you need to select an expression with no real source, as in SELECT SYSDATE FROM DUAL. Formatted like any other table reference.

Legacy joins and why they are worth spotting

Oracle supported (+) long before it supported ANSI LEFT JOIN, and enormous amounts of production code still uses it. The operator marks the deficient side — the table that gets null-extended — so WHERE e.department_id = d.department_id(+) is a left outer join keeping all employees, even though the marker sits on the departments side.

The form has real limitations that ANSI syntax does not: it cannot express a full outer join, it does not combine well with OR or IN in the same predicate, and Oracle documentation has recommended the ANSI syntax for new code since 9i. The formatter preserves whichever you wrote — putting the join conditions on their own lines is usually the fastest way to decide whether a rewrite is warranted.

How far it goes into PL/SQL

The engine is a SQL pretty-printer with PL/SQL awareness, not a full PL/SQL formatter. SQL statements inside a block are formatted properly, and block keywords such as BEGIN, END, IF, LOOP and COMMIT are placed on their own lines. Deeply nested procedural code — nested loops, exception handlers, cursor definitions inside a large package body — comes out laid out but not always indented the way a dedicated PL/SQL beautifier would do it.

It also does not validate. It has no data dictionary, does not connect to an instance, and cannot tell you whether a package compiles. It does check for unbalanced parentheses and odd quote counts, and reports the statement count so you can confirm the whole script arrived.

Common questions

Oracle Formatter FAQ

Does it support PL/SQL packages and procedures?

It formats the SQL inside them and lays out the block keywords. It is not a full procedural formatter, so a large package body will be readable but not beautified to the standard of a dedicated PL/SQL tool.

Why is the slash on its own line?

Because that is the only place SQL*Plus accepts it. The slash is a client command that executes the buffered block; it must be alone on its line with nothing else, including no semicolon.

Will it convert (+) joins to ANSI JOIN syntax?

No. That is a semantic rewrite, not a formatting change, and getting it wrong changes results. The formatter preserves the operator exactly where you wrote it.

Does Oracle support LIMIT?

No. Oracle 12c and later use FETCH FIRST n ROWS ONLY; older code uses a ROWNUM predicate in an outer query. Pasting a LIMIT clause with the Oracle dialect selected will produce a parse error, which is the parser correctly telling you the query is not Oracle SQL.