ERROR: invalid input syntax for type integer: "abc"

A string couldn’t be converted to the column’s type (integer, numeric, boolean, date…).

Seen on: PostgreSQL

Meaning

Empty strings, "undefined"/"null" strings from JavaScript, or text in numeric columns. PostgreSQL never treats '' as NULL.

Common causes

  • Empty string '' for numeric columns
  • "undefined" from a frontend
  • Wrong parameter order in queries

⚡ Quick fix

  1. Send NULL instead of ''
  2. Validate/parse input before querying
  3. Check parameter positions

Detailed fix by platform

PostgreSQL

  1. INSERT INTO items (qty) VALUES (NULLIF($1, '')::int);

How to diagnose

  1. Value — Quoted in the message
  2. Column — Expected type

🧠 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.