PL/SQL Formatter
Format Oracle SQL and PL/SQL with Oracle rules for q'[...]' alternative quoting, N'' strings, double-quoted identifiers, :bind variables and the slash that runs a block in SQL*Plus. CONNECT BY, START WITH, RETURNING and MINUS are kept as clauses, and BEGIN and END blocks with IF and LOOP are indented. Unclosed strings and parentheses are reported with line and column for Oracle developers.
Frequently asked questions
Which Oracle syntax is understood?
Single-quoted strings with doubled quotes, alternative quoting such as q'[it's]' or q'{...}' and N'' national strings are recognized. Double-quoted identifiers, names with # and $ such as emp#, :bind variables and := assignments are kept intact.
Can it format PL/SQL blocks?
Yes. BEGIN and END sections, IF THEN ELSE END IF, CASE and LOOP constructs are indented, with each statement on its own lines. Declarations before BEGIN are kept as their own statements.
What happens to the slash line?
A line that contains only /, which runs the previous block in SQL*Plus and SQLcl, stays on its own line. It separates the blocks before and after it.
Which Oracle clauses get their own line?
Hierarchical queries keep CONNECT BY and START WITH as clauses. RETURNING and the MINUS set operator are handled like the standard clauses SELECT, FROM, WHERE, GROUP BY and ORDER BY.
Does it support MERGE?
Yes. WHEN MATCHED THEN and WHEN NOT MATCHED THEN branches start new lines, so Oracle MERGE statements stay readable.
Are comments kept?
Yes. -- line comments and /* block comments */ are kept in place. Optimizer hints such as /*+ INDEX(e) */ stay exactly as written.
Does it change keyword case?
No. Keywords and identifiers keep the case you wrote. Unquoted Oracle names are case insensitive, quoted ones are not, and both stay as they are.
Which errors are detected?
Unclosed strings, alternative quotes, quoted identifiers and block comments, and unbalanced parentheses, each with line and column. Packages and grammar are not compiled.
How large can the input be?
Up to 1 MB per request and 128 KB per statement or block. Larger packages can be formatted in parts.
Can I choose the indentation, and is my code stored?
Use 2 or 4 spaces or tabs. The code is formatted in memory only and never saved.