Home › Developer Tools › MySQL to PostgreSQL Converter

MySQL to PostgreSQL Converter

Paste a mysqldump, a phpMyAdmin export or just CREATE TABLE statements and get PostgreSQL-ready SQL. Backticks, AUTO_INCREMENT, MySQL-only types, ENUMs, engine and charset clauses, zero dates and string escapes are converted, and anything that needs a human decision is listed in the review notes.

Last updated:

Conversion options
Advertisement
Advertisement

How to use the MySQL to PostgreSQL Converter

  1. Paste your MySQL SQL or open a .sql file. A sample dump is loaded so you can see the result first.
  2. Pick the options that match your target design: identity or serial, how to store ENUMs, timestamps with or without time zone.
  3. Read the review notes under the buttons; they list functions, routines and values that need a decision.
  4. Download the .sql file or copy it, then run it with psql, for example psql -d mydb -f sample-postgres.sql.
  5. Test on a copy first and compare row counts between the two databases.

MySQL to PostgreSQL type mapping

MySQLPostgreSQLNotes
TINYINT(1), BIT(1), BOOLBOOLEAN0/1 values become false/true. Other TINYINT widths become SMALLINT.
TINYINT, SMALLINTSMALLINTSMALLINT UNSIGNED becomes INTEGER so values up to 65,535 still fit.
MEDIUMINT, INTINTEGERINT UNSIGNED becomes BIGINT (PostgreSQL has no unsigned types).
BIGINTBIGINTBIGINT UNSIGNED above 263−1 needs NUMERIC(20).
INT AUTO_INCREMENTINTEGER GENERATED BY DEFAULT AS IDENTITYOr SERIAL / BIGSERIAL.
FLOAT / DOUBLEREAL / DOUBLE PRECISIONUse NUMERIC for money and exact values.
DECIMAL(p,s)NUMERIC(p,s)A bare DECIMAL means DECIMAL(10,0) in MySQL.
VARCHAR(n), CHAR(n)sameCharacter set and collation clauses are removed.
TINYTEXT … LONGTEXTTEXTPostgreSQL TEXT has no small/medium/long variants.
BLOB, VARBINARY, BINARYBYTEAHex literals (0x… or X'…') become '\x…'.
DATETIME(n)TIMESTAMP(n)Or TIMESTAMPTZ if you store moments in time across zones.
TIMESTAMPTIMESTAMP / TIMESTAMPTZMySQL TIMESTAMP is stored in UTC, which matches TIMESTAMPTZ.
YEARSMALLINTAdd a CHECK if you need the 1901-2155 range.
JSONJSONBJSONB is indexed and compared faster; JSON keeps key order and whitespace.
ENUM('a','b')CREATE TYPE … AS ENUMOr VARCHAR + CHECK, or TEXT.
SET('a','b')VARCHARConsider TEXT[] or a join table.
GEOMETRY, POINT…PostGIS geometryRequires the PostGIS extension.

Syntax that changes

MySQLPostgreSQL
`order`"order" (reserved words stay quoted)
'O\'Neil', 'a\nb''O''Neil', E'a\nb'
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4removed (the database encoding applies)
KEY idx (col) inside CREATE TABLECREATE INDEX idx ON table (col);
INSERT IGNOREINSERT … ON CONFLICT DO NOTHING
ON DUPLICATE KEY UPDATE a = VALUES(a)ON CONFLICT (id) DO UPDATE SET a = EXCLUDED.a
IFNULL(a, b), IF(c, x, y)COALESCE(a, b), CASE WHEN c THEN x ELSE y END
GROUP_CONCAT(x SEPARATOR ';')STRING_AGG((x)::text, ';')
LIMIT 10, 20LIMIT 20 OFFSET 10
CURDATE(), UNIX_TIMESTAMP()CURRENT_DATE, EXTRACT(EPOCH FROM CURRENT_TIMESTAMP)::bigint
col REGEXP 'x'col ~* 'x' (MySQL regex matching is case-insensitive by default)

A safe migration checklist

  1. Dump the schema and data: mysqldump --single-transaction --skip-triggers --hex-blob dbname > dump.sql. --hex-blob keeps binary data exact.
  2. Convert the dump here and read every review note.
  3. Create an empty database with UTF-8 encoding and run the script with psql -v ON_ERROR_STOP=1 -d newdb -f dump-postgres.sql so it stops at the first error.
  4. Compare row counts per table, then spot-check dates, booleans, decimals and text with accents or emoji.
  5. Update application queries: MySQL-specific functions, LIMIT x, y, case-insensitive string comparison (PostgreSQL's = is case-sensitive; use ILIKE or citext), and backticks in code.

For translating individual queries between many SQL dialects, use the SQL Dialect Converter. To tidy the result, run it through the SQL Formatter.

Frequently asked questions

How do I convert a MySQL dump to PostgreSQL?

Export with mysqldump (or phpMyAdmin's SQL export), open the file here and download the converted script. Create an empty database in PostgreSQL and run the script with psql -d dbname -f file.sql. The converter removes MySQL-only statements, rewrites types and syntax, adds foreign keys after the data and resets sequences at the end.

What does AUTO_INCREMENT become in PostgreSQL?

By default an identity column: id INTEGER GENERATED BY DEFAULT AS IDENTITY, the SQL-standard approach recommended since PostgreSQL 10. You can choose SERIAL or BIGSERIAL instead. Both are backed by a sequence, and the script moves the sequence past the highest inserted id so new rows do not collide.

Why are backticks replaced?

MySQL quotes identifiers with backticks, while PostgreSQL uses double quotes and folds unquoted names to lowercase. By default names are lowercased and left unquoted unless they are reserved words or contain unusual characters, so you can write queries without quotes. Choose Keep case if your application relies on mixed-case names.

How are MySQL ENUM columns converted?

PostgreSQL has real enum types, so each ENUM column becomes a CREATE TYPE table_column AS ENUM (…) followed by a column of that type. Alternatively you can store the value in a VARCHAR with a CHECK constraint listing the allowed values, which is easier to change later, or as plain TEXT.

What happens to TINYINT(1) and zero dates?

TINYINT(1) and BIT(1) are MySQL's usual way to store booleans, so they become BOOLEAN and inserted 0/1 values become false/true. PostgreSQL rejects dates such as '0000-00-00', so zero dates in INSERTs become NULL and zero-date defaults are removed; NOT NULL columns that held zero dates need a real default.

Does it convert stored procedures and triggers?

No. MySQL routines and triggers use a different procedural language, so blocks between DELIMITER lines and CREATE PROCEDURE/FUNCTION/TRIGGER statements are kept as comments for you to rewrite in PL/pgSQL. The only trigger generated automatically is the one that replaces ON UPDATE CURRENT_TIMESTAMP.

Is my database dump uploaded?

No. The conversion is plain JavaScript running in your browser tab, so table definitions and data never leave your computer. Very large dumps (hundreds of megabytes) are better handled with a dedicated migration tool such as pgloader.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

SQL Dialect ConverterTranslate SQL between MySQL, PostgreSQL, SQLite, SQL Server, Oracle, BigQuery and more.SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.SQL Create Table GeneratorDefine columns, keys, defaults and indexes; get CREATE TABLE SQL for MySQL, Postgres and more.SQL to ER DiagramPaste CREATE TABLE statements and get an entity-relationship diagram with keys and links.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.GPX ViewerOpen GPX tracks on a map with distance, elevation profile, moving time, speed and splits.JSON Repair ToolFix broken JSON automatically: trailing commas, quotes, comments, truncated data, with a diff.Karnaugh Map SolverSolve 2–6 variable K-maps: click cells or enter minterms to get the minimal SOP or POS with groups.Merge Excel FilesCombine XLSX, XLS and CSV files into one workbook or append all rows into a single sheet.Parquet File ViewerOpen Apache Parquet files in your browser: schema, rows, filters and CSV or JSON export.Query CSV with SQLRun SQL on CSV, Excel, JSON and Parquet files in your browser with DuckDB. Join and export.Online Serial MonitorTalk to Arduino, ESP32 and USB serial devices in your browser: log, send, plot and save.Split Excel FileSplit an Excel sheet into several files by row count or by each value in a column, as ZIP.SQL IN Clause GeneratorTurn a pasted list into a SQL IN ('a','b') clause with quoting, dedupe and 1,000-item chunks.SQL Online CompilerRun SQL queries online on SQLite with sample databases, a result grid, CSV export and .db save.XML to XSD GeneratorGenerate an XML Schema (XSD) from sample XML: types, occurrences, attributes and namespaces.XML ValidatorCheck if XML is well-formed, see the exact line and column of each error and pretty-print it.Wildcard Mask CalculatorConvert a subnet mask or CIDR to a wildcard mask for ACLs and OSPF, with range and binary.CSV to VCF ConverterConvert a contacts CSV into a vCard (.vcf) file, mapping columns to name, phone, email and more.CSV to YAML ConverterConvert CSV rows to a YAML list of mappings with type inference and delimiter detection.Endianness ConverterSwap byte order of 16, 32 and 64-bit hex values and see big- and little-endian integers and floats.Excel to SQL ConverterTurn an Excel sheet into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.Excel to VCF ConverterTurn an Excel contact list into a vCard .vcf file for iPhone, Android, Google or Outlook.File to C ArrayConvert any file into a C or C++ byte array header, like xxd -i, with const and PROGMEM options.Image to C ArrayConvert images to monochrome, RGB565 or RGB888 C arrays for OLED, LCD and TFT displays.JSON Merge ToolDeep-merge two or more JSON objects with array concat, replace or union and a conflict rule.JSONL to CSV ConverterConvert JSON Lines / NDJSON to CSV with flattened columns; streams large files locally.PHP Unserialize OnlineDecode PHP serialize() strings to JSON, a tree or print_r, and serialize JSON back to PHP.TSV to JSON ConverterTurn tab-separated data pasted from Excel or Sheets into a JSON array or keyed object.XLS to XLSX ConverterConvert old Excel 97-2003 .xls workbooks to modern .xlsx files in your browser, several at once.XML to Excel ConverterTurn repeating XML elements into an .xlsx spreadsheet with attributes and nested data as columns.XSD to XML Sample GeneratorGenerate a sample XML document from an XSD schema, with types, attributes and namespaces.YAML to CSV ConverterTurn a YAML list of objects into CSV with dot-notation columns, custom column order and download.DOCX to Markdown ConverterConvert Word .docx to clean Markdown with headings, lists, tables, links and images in a ZIP.ES6 to ES5 ConverterTranspile modern JavaScript (ES2015+) to ES5 with Babel: targets, module format and loose mode.
See all 129 Data & File Format Converters →