How This MySQL to PostgreSQL Converter Works
Paste MySQL DDL or DML into this mysql to postgresql converter and convert mysql to postgres online instantly, updating in realtime as you type. It's a genuine mysql to postgresql syntax converter and mysql to postgresql migration tool built for schema migrations, converting data types, identifiers, and MySQL-only syntax in one pass rather than requiring separate cleanup steps, and it's a mysql to postgres sql converter free of any signup or install.
Data Type Mapping
The core of any mysql to postgres data types conversion is getting the type mapping right, and this tool handles it as a table: TINYINT(1) becomes BOOLEAN, plain INT becomes INTEGER, an UNSIGNED INT becomes BIGINT since PostgreSQL has no unsigned integer type and BIGINT covers MySQL's unsigned range, DATETIME becomes TIMESTAMP, TINYTEXT/MEDIUMTEXT/LONGTEXT all become TEXT, TINYBLOB/MEDIUMBLOB/LONGBLOB/BLOB all become BYTEA, FLOAT becomes REAL, and DOUBLE becomes DOUBLE PRECISION.
AUTO_INCREMENT, Identifiers, and MySQL-Only Clauses
As an auto_increment to serial converter, this tool recognizes the common INTEGER NOT NULL AUTO_INCREMENT and BIGINT NOT NULL AUTO_INCREMENT patterns and rewrites them to SERIAL and BIGSERIAL respectively, PostgreSQL's equivalent auto-incrementing column types. Backtick-quoted identifiers, MySQL's own convention, are converted to PostgreSQL's double-quoted identifiers. It also strips clauses that have no PostgreSQL equivalent and would otherwise cause a syntax error, ENGINE=InnoDB, DEFAULT CHARSET=utf8mb4, COLLATE=..., ROW_FORMAT=..., and a COMMENT='...' string are all removed from table definitions during mysql ddl to postgresql conversion.
MySQL Functions and Limitations
Converting mysql functions to postgresql covers the common cases: IFNULL(a, b) becomes COALESCE(a, b), IF(cond, a, b) becomes CASE WHEN cond THEN a ELSE b END, GROUP_CONCAT(x) becomes STRING_AGG(x), and MySQL's LIMIT offset, count becomes PostgreSQL's LIMIT count OFFSET offset. One honest limitation worth knowing when you convert mysql create table to postgres statements that include string literals, MySQL allows string literals in double quotes as well as single quotes, but after backtick identifiers are converted to double quotes, a double-quoted string literal in the original MySQL becomes indistinguishable from a converted identifier, so it passes through unconverted, worth a manual check if your source SQL uses double-quoted strings rather than single-quoted ones.