SQL Formatter
Formats SQL queries for MySQL, PostgreSQL, SQLite, SQL Server, and more.
Describe a table once and generate CREATE TABLE, INSERT, SELECT, UPDATE, and DELETE statements for MySQL, PostgreSQL, SQLite, or SQL Server, with identifiers and values quoted correctly.
`name` in MySQL, "name" in PostgreSQL and SQLite, and [name] in SQL Server.O'Brien becomes 'O''Brien'. Numbers are written as they are, and an empty cell or NULL becomes NULL.INT NOT NULL AUTO_INCREMENT in MySQL, INTEGER GENERATED ALWAYS AS IDENTITY in PostgreSQL, INTEGER PRIMARY KEY AUTOINCREMENT in SQLite, and INT IDENTITY(1,1) in SQL Server.Table users with id (auto-increment key), email (text, not null), and active (boolean, default true), for PostgreSQL:
CREATE TABLE "users" ( "id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, "email" VARCHAR(255) NOT NULL, "active" BOOLEAN DEFAULT TRUE );
UPDATE setting active to false where email = [email protected]:
UPDATE "users" SET "active" = FALSE WHERE "email" = '[email protected]';
Values are escaped for a one-off query you run yourself. In application code, always use prepared statements with parameters rather than building SQL strings.
MySQL uses backticks by default, while PostgreSQL, SQLite, and standard SQL use double quotes. SQL Server uses square brackets. Quoting lets you use names that clash with keywords, such as order.
Yes. Paste the rows as CSV, one per line, and the tool writes one INSERT with several value lists. All four databases accept this.
No. The tool only writes text in your browser.
Often used together with the SQL Query Generator.
Formats SQL queries for MySQL, PostgreSQL, SQLite, SQL Server, and more.
Converts PHP serialized strings to readable JSON and back, safely.
Turns a CSV table into an array of JSON objects.