06 Null

The null value is used when a key does not have a value.

It acts as a placeholder, meaning the key exists, but there is no information stored for it yet.

For example, a person's middle name may not be known, or a phone number may not have been added yet.

Example

{
    "name": "Emma",
    "middleName": null,
    "age": 14
}

In this example:

  • "name" has the value "Emma".
  • "middleName" has the value null, which means no middle name has been provided.
  • "age" has the value 14.

Rules for null

Rule 1: Write null Without Quotes

The value null must not be inside quotation marks.

✅ Correct

{
    "phoneNumber": null
}

❌ Wrong

{
    "phoneNumber": "null"
}

Why is it wrong? "null" is just the text "null". It is not the special JSON value null.

Rule 2: null Means "No Value"

Use null when a value is missing, unknown, or has not been set yet.

✅ Correct

{
    "email": null
}

This means the email address has not been provided.

❌ Wrong

{
    "email":
}

Why is it wrong? Every key in JSON must have a value. If there is no value, use null.

Rule 3: null Can Be Replaced Later

A null value can be updated when the information becomes available.

Before

{
    "favoriteColor": null
}

After the user chooses a color

{
    "favoriteColor": "Blue"
}

This shows how null acts as a temporary placeholder until a real value is added.

Summary

ValueMeaning
nullThe key exists, but it currently has no value.
"null"The word "null" stored as text (a string).

Remember

  • ✅ Write null without quotation marks.
  • ✅ Use null when a value is missing or unknown.
  • null is a placeholder that can be replaced with a real value later.
  • ❌ Do not leave a key without a value — use null instead.