SQL Viewer
Format, highlight, and inspect SQL queries and dumps.
SQL Viewer and Formatter Online
The SQL viewer makes long, minified, or machine-generated SQL readable. Paste a query or open a .sql dump and you get three views at once: neatly formatted SQL in the output editor, a syntax-highlighted rendering with coloured keywords, strings, and numbers, and — when the script contains INSERT statements — a table grid of the rows being inserted.
Formatting that understands dialects
Formatting is powered by the open-source sql-formatter library, which parses SQL with dialect-specific grammars. Pick Standard SQL, MySQL, MariaDB, PostgreSQL, SQLite, SQL Server (T-SQL) or Oracle PL/SQL so that quoting styles, operators such as :: casts, and vendor keywords are recognised. Each clause starts on its own line, column lists are broken up, and nested subqueries are indented consistently.
Options
- Keywords – force
SELECTand friends to upper or lower case, or preserve your casing. - Indentation – two or four spaces per level.
- SQL dialect – controls how the code is tokenised. If you see a parse error, the dialect is the first thing to check.
Inspecting INSERT data
Database dumps from mysqldump, phpMyAdmin, or pg_dump bury data in long VALUES lists. The viewer reads those statements and displays every table as a grid, combining multiple INSERTs into the same table and using the column list or the matching CREATE TABLE for headers. You can search, sort, and export the grid to .xlsx.
When to use it
Reviewing a slow query copied from a log, reading an ORM-generated statement during debugging, cleaning up SQL before pasting it into a pull request, or checking what a migration script will insert — all of these are easier when every clause is on its own line and the keywords stand out.
Privacy
Everything happens in the browser; queries, schema names, and data are never uploaded or executed.
Related tools
Convert the dump's data with SQL to CSV, SQL to JSON, or SQL to HTML. Build statements with the SQL Table Generator and the SQL Code Generator, and escape string literals with SQL Escape.
Frequently Asked Questions
Why do I get a parse error?
The formatter parses the statements using the grammar of the selected dialect. Identifiers quoted with backticks, for example, are only valid in MySQL, MariaDB, and SQLite, so a MySQL dump fails under PostgreSQL or SQL Server. Choose the dialect the SQL was written for; the error message shows the line and column of the problem.
Can I see the data inside INSERT statements?
Yes. When the SQL contains INSERT INTO … VALUES statements, each target table is shown as a searchable, sortable grid below the highlighted code, and you can download it as an Excel file.
Does the viewer run my queries?
No. The SQL is only formatted, highlighted, and parsed as text. Nothing is executed and no database connection is made, so it is safe to open production dumps.
Can I keep my own keyword casing?
Choose “Keep as typed” under Keywords to leave SELECT, from, Where and the rest exactly as written, while indentation and line breaks are still normalised.