Skip to main content
Use "type": "null" when a field must be present with a null value.

Example

{
  "type": "object",
  "properties": {
    "middle_name": { "type": "null" },
    "deprecated_field": { "type": "null" }
  },
  "required": ["middle_name", "deprecated_field"],
  "additionalProperties": false
}

null vs optional fields

  • type: "null": field is present and value is null.
  • Optional field: field may be absent.
  • Optional field + type: "null": field is either absent or present with null.
If you want a field that can be either string or null, use a union type:
{
  "type": "object",
  "properties": {
    "value": {
      "anyOf": [
        { "type": "string" },
        { "type": "null" }
      ]
    }
  },
  "required": ["value"],
  "additionalProperties": false
}