PL/SQL Formatter
Paste Oracle SQL or a PL/SQL block to format it with Oracle's keywords and syntax. The Oracle (PL/SQL) dialect is already selected.
Format Oracle SQL and PL/SQL code online
Oracle code copied out of a trace file, an APEX page or a one-line log entry is hard to review. This PL/SQL formatter splits it into one statement per block, puts every clause of a query on its own line and uppercases keywords, so a missing join condition or a wrong bind variable is easy to spot.
It understands Oracle syntax such as :bind variables, SELECT ... INTO, := assignments, DECLARE/BEGIN/END blocks and IF ... THEN. The code is formatted in your browser and never sent to a server, which matters when the schema belongs to a production database.
Example: a PL/SQL anonymous block
Before:
declare v_total number; begin select sum(amount) into v_total from payments where customer_id=:cust_id and status='PAID'; if v_total>1000 then update customers set tier='GOLD' where id=:cust_id; end if; commit; end;After formatting:
DECLARE v_total number;
BEGIN
SELECT
sum(amount) INTO v_total
FROM
payments
WHERE
customer_id = :cust_id
AND status = 'PAID';
IF v_total > 1000 THEN
UPDATE customers
SET
tier = 'GOLD'
WHERE
id = :cust_id;
END IF;
COMMIT;
END;Each SQL statement inside the block is laid out clause by clause and separated by a blank line. The statements inside BEGIN ... END are not indented one extra level, so for long packages you may still want to adjust nesting by hand.
Frequently asked questions
- Does it work for plain Oracle SQL, not just PL/SQL?
- Yes. Ordinary SELECT, INSERT, UPDATE, DELETE and MERGE statements written for Oracle format the same way. The PL/SQL dialect simply adds Oracle's keywords and block syntax.
- Can I format a whole package or procedure?
- You can paste a full CREATE PROCEDURE or package body and each statement will be formatted. Very complex nesting is formatted statement by statement rather than re-indented as a tree.
- Are bind variables like :cust_id kept as they are?
- Yes. Bind variables, quoted strings and identifiers are left exactly as written. Only whitespace, line breaks and keyword case change.
- Is my Oracle code uploaded anywhere?
- No. The formatter runs entirely in your browser with JavaScript, so table names, column names and data stay on your computer.