Oracle SQL Formatter (PL/SQL)
Format and beautify Oracle SQL and PL/SQL: :bind variables, FETCH FIRST, NVL and DUAL — with keyword case, indentation and line-break options.
How to use this tool
Steps for using the SQL Formatter.
- Paste your Oracle PL/SQL query into Input SQL — Oracle PL/SQL is already selected under Dialect, so its quoting, parameters and operators are understood.
- Pick Keyword case (UPPERCASE, lowercase or Preserve) and Indentation, and open Formatting options for indent style, AND / OR placement and line width.
- Choose an Action: Format to beautify, Minify to put it on one line, Validate to check the syntax, or Explain for a plain-English summary.
- Copy or download the result. Formatting only changes whitespace and keyword case — the query does the same thing.
Example
FETCH FIRST and Oracle date functions
select e.employee_id, e.last_name, d.department_name from employees e join departments d on d.department_id = e.department_id where e.hire_date > add_months(sysdate, -12) order by e.hire_date desc fetch first 10 rows onlySELECT
e.employee_id,
e.last_name,
d.department_name
FROM
employees e
JOIN departments d ON d.department_id = e.department_id
WHERE
e.hire_date > add_months(sysdate, -12)
ORDER BY
e.hire_date DESC
FETCH FIRST
10 rows ONLYCommon use cases
- Reading long reporting queries from SQL Developer, TOAD or AWR reports.
- Reviewing SQL embedded in PL/SQL packages before deployment.
- Formatting queries with :bind variables from application logs.
- Preparing readable SQL for tickets and documentation.
Formatting Oracle SQL and PL/SQL
Oracle has syntax of its own: bind variables written :emp_id, functions such as NVL, ADD_MONTHS and SYSDATE, the DUAL table, and — since Oracle 12c — FETCH FIRST n ROWS ONLY for limiting rows. With the Oracle PL/SQL dialect selected, the formatter recognises these instead of treating :emp_id as an error.
Formatting puts each clause on its own line and indents joins and conditions, which makes long reporting queries from SQL Developer, TOAD or application logs much easier to review. Only layout and keyword case change; the query does the same thing.
Bind variables matter for performance and security: they let Oracle reuse execution plans and keep user input out of the SQL text. Keeping them visible in a formatted query makes it easy to see which values come from the application.
Other databases: SQL Server, MySQL, PostgreSQL.
Limitations
- The formatter doesn't know your database schema — unknown tables or columns aren't detected.
- Large PL/SQL packages are best formatted one procedure or statement at a time.
- Comments are kept, but their position may change slightly around reformatted lines.
Frequently asked questions
How do I format SQL in Oracle SQL Developer?
SQL Developer has a Format command (Ctrl+F7). To format without it, or with consistent settings across tools, paste the query here with the Oracle PL/SQL dialect selected.
Are :bind variables kept?
Yes. Bind variables such as :emp_id are recognised and left exactly as written.
Does it support FETCH FIRST?
Yes. FETCH FIRST … ROWS ONLY is formatted as its own clause. Older ROWNUM-based queries are formatted too.
Is my query sent to a server?
No. The Oracle SQL formatter runs entirely in your browser.