I Help You

SQL UPSERT Generator

Generate INSERT ON DUPLICATE KEY UPDATE (MySQL), ON CONFLICT DO UPDATE (PostgreSQL), INSERT OR REPLACE (SQLite), or MERGE (MSSQL). Free, and it runs entirely in your browser — nothing you enter is uploaded.

How to use the SQL UPSERT Generator

1. Set the table name, dialect, and the unique/conflict column (usually id or email).

2. Enter key=value pairs for all columns — one per line.

3. Click Generate UPSERT — the conflict column is excluded from the UPDATE SET clause.

What is it?

An UPSERT inserts a row if it doesn't exist, or updates it if a conflict occurs on a unique key. Each database implements this differently: MySQL uses ON DUPLICATE KEY UPDATE, PostgreSQL uses ON CONFLICT DO UPDATE, SQLite uses INSERT OR REPLACE, and MS SQL Server uses a MERGE statement.

Example

key=value pairs
id=1
name=John
[email protected]
↓
MySQL UPSERT
INSERT INTO users (id, name, email)
VALUES (1, 'John', '[email protected]')
ON DUPLICATE KEY UPDATE
  name = 'John',
  email = '[email protected]';

Benefits

Generate INSERT and CREATE TABLE statements instantly

Convert JSON, CSV, or a field list into ready-to-run SQL in seconds — no manual quoting, no counting columns, no copy-paste errors from spreadsheet data.

Build SELECT queries without memorising syntax

The visual query builder constructs WHERE conditions, ORDER BY, LIMIT, and DISTINCT clauses interactively — useful for anyone who writes SQL occasionally rather than daily.

Migrate between MongoDB and relational databases

Convert MongoDB find, insert, update, and delete operations directly to SQL equivalents — speed up data migration planning or schema exploration.

All your data stays in the browser

No SQL query, schema definition, or database content is ever uploaded to a server. Everything runs entirely client-side, making these tools safe to use with sensitive data.

Frequently asked questions

What is the unique/conflict column?

The column that causes a conflict when a duplicate is inserted — usually the PRIMARY KEY or a UNIQUE-constrained column (e.g. id, email, username).

Why is SQLite different?

SQLite's INSERT OR REPLACE deletes the conflicting row and re-inserts — it doesn't support partial column updates. Use it carefully if you have foreign key dependencies.