MySQL → PostgreSQL
Convert MySQL JSON to PostgreSQL jsonb
Both engines store JSON natively, so data migrates cleanly. On the PostgreSQL side you almost always want jsonb — it's indexed, faster to query, and deduplicates keys.
JSON → json / jsonb
What to know
- Values transfer as-is; the engine mapping is json (cast to jsonb after import if desired)
- MySQL's JSON_EXTRACT(doc,'$.a') becomes doc->'a' / doc->>'a'
- jsonb supports GIN indexes: CREATE INDEX ON t USING gin (doc)
- Key order is not preserved in jsonb (it is in json) — don't rely on it
Before / after
MySQL
SELECT JSON_EXTRACT(prefs, '$.theme') FROM users; PostgreSQL
SELECT prefs->>'theme' FROM users;
-- after: ALTER TABLE users ALTER prefs TYPE jsonb USING prefs::jsonb; Don't convert column-by-column — convert the whole database.
Upload a dump, get back ready-to-import SQL with this mapping (and every other one) applied.
Open the MySQL → PostgreSQL converterSee the full type mapping table or all guides.