Convert MySQL to Postgres (and Postgres to MySQL) Online
Moving a database between engines usually means rewriting CREATE TABLE statements, data types and query syntax by hand. This free converter does the heavy lifting: paste your SQL, pick the source and target, and get clean, ready-to-review code for PostgreSQL, MySQL or SQLite, with nothing to install.
What is a MySQL to Postgres converter?
MySQL and PostgreSQL both speak SQL, but each has its own dialect. MySQL uses backticks around names and AUTO_INCREMENT for counters; PostgreSQL uses double quotes and identity columns or SERIAL. Types, defaults, index syntax and even string comparison rules differ too. A MySQL to Postgres converter translates those differences automatically, so a schema or query written for one engine can run on the other.
This tool converts in both directions, so it works as a Postgres to MySQL converter online as well, and it can translate MySQL statements for SQLite when you need a lightweight embedded database. It focuses on the part developers dread most: rewriting table definitions and queries line by line.
How to convert MySQL to Postgres
- Paste your MySQL SQL into the input box. A single
CREATE TABLE, a batch of statements or a query all work. - Select the direction: MySQL → PostgreSQL (or PostgreSQL → MySQL, or MySQL → SQLite).
- Click Convert. Data types, quoting, auto-increment keys and common functions are rewritten for the target.
- Copy the result and run it against a test database first. Tidy it up with our SQL beautifier if you want it neatly formatted.
Prefer to work from a full mysqldump file? Convert the schema here, then move rows with a loader such as pgloader or COPY, as described in the PostgreSQL documentation.
Convert a MySQL CREATE TABLE to Postgres (example)
Here is a typical MySQL table and what the same table looks like in PostgreSQL after conversion:
CREATE TABLE `orders` (
`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`status` ENUM('new','paid','shipped') NOT NULL,
`total` DECIMAL(10,2) NOT NULL,
`is_gift` TINYINT(1) DEFAULT 0,
`meta` JSON,
`placed_at` DATETIME NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE "orders" (
"id" BIGINT GENERATED BY DEFAULT
AS IDENTITY PRIMARY KEY,
"status" TEXT NOT NULL
CHECK ("status" IN ('new','paid','shipped')),
"total" NUMERIC(10,2) NOT NULL,
"is_gift" BOOLEAN DEFAULT FALSE,
"meta" JSONB,
"placed_at" TIMESTAMP NOT NULL
);
MySQL ↔ PostgreSQL data type mapping
Getting types right is the heart of any conversion. These are the mappings you’ll see most often. For the full lists, see the official MySQL data types reference.
| MySQL | PostgreSQL | Notes |
|---|---|---|
INT AUTO_INCREMENT |
GENERATED … AS IDENTITY or SERIAL |
Identity columns are the modern standard. |
TINYINT(1) |
BOOLEAN |
Plain TINYINT becomes SMALLINT. |
INT UNSIGNED / BIGINT UNSIGNED |
BIGINT / NUMERIC(20) |
PostgreSQL has no unsigned types, so the next size up is used. |
DATETIME |
TIMESTAMP |
Use TIMESTAMPTZ if you need time zones. |
DOUBLE |
DOUBLE PRECISION |
|
VARCHAR(n), CHAR(n) |
VARCHAR(n), CHAR(n) |
Unchanged. TEXT works well too. |
MEDIUMTEXT, LONGTEXT |
TEXT |
PostgreSQL TEXT is effectively unlimited. |
BLOB, LONGBLOB |
BYTEA |
|
ENUM('a','b') |
CREATE TYPE … AS ENUM or CHECK |
A CHECK constraint is easier to change later. |
JSON |
JSON / JSONB |
JSONB is indexed and faster to query. |
Backticks `name` |
Double quotes "name" |
|
LIMIT 10, 20 |
LIMIT 20 OFFSET 10 |
|
IFNULL(a,b) |
COALESCE(a,b) |
|
ENGINE=InnoDB, CHARSET=… |
Removed | PostgreSQL has no table engines. |
Convert Postgres to MySQL
Going the other way is just as common: a team standardizes on MySQL or MariaDB for hosting, or needs a schema that a MySQL-only CMS or plugin can read. When you convert Postgres to MySQL, the converter reverses the mapping above:
SERIAL/ identity columns becomeAUTO_INCREMENTBOOLEANbecomesTINYINT(1)BYTEAbecomesBLOB, andJSONBbecomesJSON- Double-quoted names become backtick-quoted names
- PostgreSQL-only syntax such as
::casts andILIKEis rewritten withCAST()andLIKE
RETURNING clauses. These are flagged or approximated (for example, arrays stored as JSON), so review them by hand.MySQL to SQLite query migration
SQLite is a lightweight, file-based database that’s ideal for local development, mobile apps and tests. A MySQL to SQLite query migration tool has to handle an even bigger jump, because SQLite uses just a handful of storage classes. The usual rewrites are:
| MySQL | SQLite |
|---|---|
INT AUTO_INCREMENT PRIMARY KEY |
INTEGER PRIMARY KEY AUTOINCREMENT |
VARCHAR(n), TEXT, DATETIME |
TEXT |
INT, BIGINT, TINYINT(1) |
INTEGER |
DECIMAL, FLOAT, DOUBLE |
NUMERIC / REAL |
ENUM('a','b') |
TEXT with a CHECK constraint |
SQLite is flexible about types, which is convenient but means values aren’t strictly enforced. Read how it works in the official SQLite datatypes guide before relying on it for production data.
Why use this converter?
You could rewrite every statement manually, or write a script, but a dedicated converter is faster and less error-prone. Here’s why people use a tool like this for MySQL, Postgres and SQLite migrations:
No installation
Works in the browser on Windows, Mac and Linux. No MySQL or PostgreSQL server needed just to translate syntax.
Both directions
One tool for MySQL → Postgres, Postgres → MySQL and MySQL → SQLite, instead of three separate scripts.
Handles the tedious parts
Quoting, auto-increment keys, type mapping and engine clauses are rewritten consistently across every table.
Instant feedback
See the converted SQL immediately, tweak your input, and convert again until it’s right.
Benefits of converting MySQL to Postgres
Teams move from MySQL to PostgreSQL for a range of practical reasons. The main benefits people look for are:
- Closer SQL standards: PostgreSQL follows the SQL standard closely, which makes queries more portable.
- Richer data types:
JSONB, arrays, ranges and UUIDs are built in. - Advanced features: window functions, common table expressions and a large extension ecosystem (such as PostGIS for geographic data).
- Strong consistency: robust constraints and transactional behavior suit data-critical applications.
- Less manual work: converting the schema automatically means you spend your time on testing rather than retyping.
Neither database is “better” for every project. MySQL remains a great choice for many web apps, including WordPress sites, which are built on it. The right choice depends on your workload, your team and your hosting.
What to check after converting
Automatic conversion handles the mechanical differences, but a few behaviors differ at runtime, so always test before going live:
- Case sensitivity: MySQL string comparisons are typically case-insensitive by default; PostgreSQL’s are case-sensitive. Use
ILIKEorLOWER()where needed. - Zero dates: values like
0000-00-00are valid in some MySQL setups but rejected by PostgreSQL. Clean them toNULL. - Unsigned numbers: check that widened integer types still fit your data and your application code.
- Stored procedures and triggers: procedural code differs most between engines and usually needs manual rewriting.
- Indexes and keys: confirm every primary key, unique key and index made it across, and that identity sequences start after your highest existing ID.
- Test on a copy: run converted SQL on a staging database and compare row counts before touching production.
INSERT statements, or the JSON to SQL converter for API data.Related tools
- CSV ↔ SQL converter: turn CSV files into SQL tables and queries, and back.
- JSON ↔ SQL converter: move JSON data in and out of SQL.
- SQL minifier and beautifier: format converted SQL so it’s easy to review.
- WordPress query generator: build WP_Query code for MySQL-powered WordPress sites.
See every utility in our free online tools collection.
Frequently asked questions
How do I convert MySQL to Postgres?
Paste your MySQL CREATE TABLE statement or query into the converter, choose MySQL → PostgreSQL, and click Convert. Copy the result and run it on a test PostgreSQL database first.
How do I convert a MySQL CREATE TABLE to Postgres?
The converter rewrites the table definition for you: backticks become double quotes, AUTO_INCREMENT becomes an identity column, TINYINT(1) becomes BOOLEAN, DATETIME becomes TIMESTAMP, and engine and charset clauses are removed.
Is there a Postgres to MySQL converter online?
Yes. Switch the direction to PostgreSQL → MySQL. Identity columns, BOOLEAN, BYTEA and JSONB are mapped to their MySQL equivalents, and PostgreSQL-only syntax is flagged.
Can I migrate MySQL queries to SQLite?
Yes. Choose MySQL → SQLite to convert AUTO_INCREMENT, quoting and column types to SQLite syntax. Remember that SQLite’s type system is looser than MySQL’s.
Will the converter move my data too?
The converter translates SQL statements, meaning table definitions and queries. For large datasets, convert the schema first, then load rows with a dedicated import tool and verify the counts.
Is the conversion 100% accurate?
It handles the common mappings reliably, but database engines differ in behavior as well as syntax. Always review the output and test it before using it in production.
What is the difference between MySQL and PostgreSQL?
Both are open-source relational databases. MySQL is known for simplicity and wide hosting support; PostgreSQL is known for standards compliance, advanced data types and extensibility. Their SQL dialects differ, which is why conversion is needed when you switch.
Is this MySQL to Postgres converter free?
Yes, it’s free to use in your browser, with no installation required.