malformed array literal 🐘 PostgreSQL

ERROR: malformed array literal: "x"

A value sent to an array column isn’t in PostgreSQL array syntax ({a,b}).

Seen on: PostgreSQL

Meaning

Drivers that don’t map arrays, JSON strings sent to text[] columns, or comma-separated strings.

Common causes

  • Sending a JSON string or CSV to an array column
  • ORM not mapping arrays
  • Missing braces

⚡ Quick fix

  1. Pass native arrays through the driver
  2. Use ARRAY['a','b'] or '{a,b}' literals
  3. Use jsonb if you’re storing JSON

Detailed fix by platform

Node.js

  1. pool.query('UPDATE posts SET tags = $1 WHERE id = $2', [['news', 'tech'], id]);

How to diagnose

  1. Value — What string was sent?
  2. Column — Array or jsonb?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.