JSON null vs Empty String vs Missing Key: What's the Difference?

Three ways to express "no value" in JSON — and they're not interchangeable. Choosing wrong leads to bugs that are easy to miss in tests and painful to debug in production.

What each one means

{
  "name": null,
  "nickname": "",
  "middleName": null
}

versus a key that simply isn't there at all:

{
  "name": "Alice"
}
  • null — the key exists, the value is explicitly absent. You're saying "I know this field, and it has no value."
  • "" — the key exists, the value is a zero-length string. This is a value — it just happens to be empty.
  • missing key — the field isn't present at all. The receiver has to decide whether that means "not set", "not applicable", or "use the default."

Why it matters in practice

When you receive JSON, null and missing are often treated identically in JavaScript:

const obj = { name: null };
obj.name;         // null
obj.middleName;   // undefined
obj.name ?? "?";  // "?"
obj.middleName ?? "?";  // "?"

But in stricter systems — typed languages, JSON Schema validators, databases — they're completely different. A SQL column that forbids NULL will reject a null value but happily store "".

The practical rules

Use null when a field is defined in your schema but has no value for this record. A user who skipped the optional "bio" field gets "bio": null, not a missing key.

Use "" only when the empty string is a meaningful value — for example, a user who deliberately set their display name to blank (though you'd usually want to reject that as invalid input).

Omit the key when the field isn't applicable to this object type, or when you're sending a sparse update patch and only including changed fields.

A common mistake

Storing "" when you mean "not set" causes problems later. Searching for users with no bio becomes WHERE bio IS NULL OR bio = '' instead of the clean WHERE bio IS NULL. Pick one representation and stick to it.

Validate your JSON

Paste your JSON into the JSON formatter and validator to check structure and spot unintended nulls or missing required fields. See also common JSON syntax errors for the mistakes that most often break parsers.

Got a config file to check?

Open the config toolkit →