SQL Formatter

SQL Formatter

SQL Input1 lines
Formatted Output
Formatted result will appear here...

How to Use

1. Enter SQL Query
Paste the SQL query you want to format in the left input area. Single-line queries from logs work great!
2. Configure Options
Set indent size (2, 4, or 8 spaces) and toggle keyword uppercase conversion as needed.
3. Click Format
Click 'Format' to display the beautifully formatted SQL on the right.
4. Copy Result
Use 'Copy' to copy to clipboard, or click ↕ to send the result back to the input for further editing.

Comments & questions

What is a SQL Formatter?

The SQL Formatter is a free online tool that auto-indents and beautifies messy single-line SQL queries into clean, readable format. It applies keyword line breaks, auto-indentation, and syntax highlighting so you can understand even complex queries at a glance.

It supports 6 SQL dialects including MySQL formatter, PostgreSQL formatter, Oracle (PL/SQL), SQL Server (T-SQL), SQLite, and Standard SQL. Features include keyword case conversion, adjustable indentation, SQL minification, and .sql file upload/download.

Key Features

6 SQL Dialects

Select MySQL, PostgreSQL, Oracle, SQL Server, SQLite, or Standard SQL to apply dialect-specific formatting rules.

Syntax Highlighting

Keywords are highlighted in blue, strings in green, numbers in orange, and comments in gray for improved code readability.

Keyword Case & Indentation

Automatically convert SQL keywords like SELECT, FROM to uppercase, and freely adjust indentation size (2/4/8 spaces).

Minify & File Management

Compress formatted SQL into a single line (Minify), or upload/download .sql files for convenient management.

How to Use

  1. Enter SQL Query — Paste the SQL query you want to format in the left input area, or upload a .sql file.
  2. Configure Options — Set the SQL Dialect, indent size (2/4/8 spaces), and keyword uppercase conversion.
  3. Click Format — Click 'Format' to see the syntax-highlighted, formatted result on the right.
  4. Copy / Save Result — Use 'Copy' to copy to clipboard, or download as a .sql file.

Use Cases

Code Review

Format SQL queries in pull requests so team members can easily understand and review them.

Debugging & Log Analysis

Beautify single-line SQL from logs to quickly identify the root cause of issues.

Learning & Education

Help students and junior developers understand query structure by formatting SQL into readable blocks.

Documentation

Clean up SQL for inclusion in technical documents, database design specs, and reports.

Frequently Asked Questions

What SQL dialects does the formatter support?

It supports standard SQL syntax used in MySQL, PostgreSQL, Oracle, SQL Server, SQLite, and more. It can format SELECT, INSERT, UPDATE, DELETE queries with JOINs and subqueries.

Can I format a single-line SQL from logs?

Yes, paste the single-line SQL query and click 'Format'. Keywords will be separated with line breaks and indentation for easy reading.

Is my SQL sent to any server?

No. All processing happens in your browser. Your SQL is never transmitted to any server.

What does uppercase keywords mean?

It automatically converts SQL keywords (SELECT, FROM, WHERE, etc.) to uppercase. This is a common convention to improve SQL readability.

Can I use it as a MySQL or PostgreSQL formatter?

Yes, it supports 6 SQL dialects: MySQL formatter, PostgreSQL formatter, Oracle, SQL Server (T-SQL), SQLite, and Standard SQL. Select your desired engine from the SQL Dialect dropdown to apply dialect-specific formatting.

Does it work on mobile devices?

Yes, it is fully responsive and works on smartphones and tablets. On mobile, the input and output panels stack vertically for comfortable touch-based SQL formatting.

Privacy Notice

All processing in the SQL Formatter happens entirely in your browser. Your SQL queries are never sent to any server. Feel free to use it with work queries or SQL containing sensitive data.

Related Tools

JSON FormatterJSON ↔ CSVCSS MinifierUUID GeneratorWasm Module InspectorHreflang Matrix CheckerAST Query PlaygroundContainer Build GraphDependency Graph ExplorerSemver Range LabCron Schedule AuditorPatch Review WorkbenchSource Map ExplorerLocalization Catalog AuditorStructured Data ReviewerHTTP Archive AnalyzerWebhook Signature LabProtobuf Schema WorkbenchGraphQL Schema LabAvro Schema EvolutionLocal SQL WorkbenchSchema Form BuilderMesh Repair WorkbenchPipe Network LabRobot Arm Kinematics LabThermal Network LabBeam Response LabGear Train DesignerTolerance Stackup LabSensor Calibration FitPCB Stackup PlannerDigital Filter DesignerNetwork Reachability MapSun Shadow MapGPS Error SimulatorDigital Logic SimulatorAnalog Circuit LabMechanism Linkage LabAnalysis Mesh GeneratorOpenAPI Contract InspectorDatabase Migration PlannerDimensional Equation CheckerTruss Force LabBoolean Minimization LabControl Response LabQueueing Simulation LabGeofence Event SimulatorCoordinate Reference LabSurvey Traverse LabRaster Classification LabChoropleth Design LabMap Print ComposerRaster Reprojection LabElevation Contour MakerTerrain Viewshed LabWatershed DelineatorMap Tile PackagerText File Encoding WorkbenchFilesystem Portability AuditorSBOM License ExplorerFile Signature Auditornpm Lockfile Conflict ResolverSource Secret AuditorOffline Web Package BuilderCertificate Chain InspectorTorrent Metainfo InspectorChunked File PackagerEncrypted File VaultDuplicate File FinderArchive WorkbenchDesign Token ManagerSpacing Token DesignerResponsive Type SystemPackaging Dieline DesignerSVG Icon Sprite PackerFlex Layout PlaygroundCSS Grid PlaygroundRegex Equivalence LabMarkdown Repository AuditorLog Template MinerResponsive Layout AuditorEmail Template PreviewInternal Link GraphState Machine TesterPetri Net SimulatorGit History VisualizerCurl Request WorkbenchBinary Protocol DesignerHex File EditorBinary Patch WorkbenchFile Signature WorkbenchAPI Mock SandboxSchema Column MapperEvent Log SessionizerER Diagram DesignerTime Series Gap AuditorStratified Data SplitterData Lineage DesignerDecision Tree LabData Anonymization WorkbenchData Expectation RunnerJSON Schema ValidatorBasket Pattern AnalyzerRobots Policy TesterSEO HTML AuditorAccessibility Structure AuditorSyndication Feed WorkbenchIndexNow Payload BuilderCrawl Log AnalyzerCSP Policy WorkbenchSearch Performance AnalyzerCSV Formula Risk AuditorCORS Response SimulatorCache Header LabCookie Policy InspectorWeb Vitals Trace LabSitemap Health AuditorBatch File RenamerFile Manifest VerifierFolder Space MapFolder Difference ReviewerRoute Order OptimizerGeoJSON Map EditorPolygon Overlay LabCartographic Label PlacerSpatial Table JoinGeoJSON Topology AuditorGPX Track AnalyzerTrack Privacy RedactorCSV Table JoinCSV Pivot WorkbenchScientific Data ProfilerTabular Cleaning WorkbenchRecord ReconciliationData Dictionary BuilderCanonical Graph AuditorRedirect Plan TesterHTTP response and ping reference testBrowser and System InformationJSON ↔ YAML ConverterXML ↔ JSON ConverterHTML FormatterJavaScript MinifierMock Data Generator.gitignore GeneratorLicense GeneratorUser-Agent ParserPassword Strength CheckerCode to ImageXML FormatterHTTP Status Code LookupMIME Type LookupJS & SQL String EscapeCSS Box Shadow GeneratorCSS Gradient GeneratorIndent ConverterNumber Base ConverterUnicode Escape ConverterUnicode InspectorJSON Structure DiffMarkdown Table GeneratorBase64 EncoderURL EncoderCron Expression GeneratorRegex TesterHash GeneratorTimestamp ConverterJWT DecoderHTML Entity ConverterMarkdown PreviewMeta Tag GeneratorCase ConverterImage to Base64
Explore all Dev Tools tools →Image/Media →Text/Convert →Life/Fun →