Exclusive Minimum and Maximum in JSON Schema

Use exclusiveMinimum and exclusiveMaximum in JSON Schema to set strict numeric bounds. Learn the difference from inclusive ranges and draft compatibility.

Number Constraints

JSON Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "temperature": {
      "type": "number",
      "exclusiveMinimum": -273.15,
      "description": "Temperature in Celsius (above absolute zero)"
    },
    "opacity": {
      "type": "number",
      "exclusiveMinimum": 0,
      "exclusiveMaximum": 1,
      "description": "Opacity value, strictly between 0 and 1"
    },
    "age": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 150
    }
  },
  "required": ["temperature"]
}

Test Data

{
  "temperature": 22.5,
  "opacity": 0.75,
  "age": 30
}

Detailed Explanation

Exclusive Bounds in JSON Schema

While minimum and maximum define inclusive bounds (the boundary values themselves are valid), exclusiveMinimum and exclusiveMaximum define strict bounds where the boundary values are not allowed.

Inclusive vs. Exclusive

// Inclusive: value >= 0 AND value <= 100
{ "minimum": 0, "maximum": 100 }

// Exclusive: value > 0 AND value < 100
{ "exclusiveMinimum": 0, "exclusiveMaximum": 100 }

// Mixed: value > 0 AND value <= 100
{ "exclusiveMinimum": 0, "maximum": 100 }

With inclusive bounds, 0 and 100 are valid. With exclusive bounds, they are not — only values strictly between the boundaries pass.

How the Example Schema Works

The schema uses exclusive bounds for three scientifically meaningful constraints:

  1. temperatureexclusiveMinimum: -273.15 enforces that the temperature must be above absolute zero (-273.15 degrees C). The value -273.15 itself is invalid because nothing can be at or below absolute zero in classical physics. The value 22.5 passes comfortably.

  2. opacity — both exclusiveMinimum: 0 and exclusiveMaximum: 1 create the open interval (0, 1). Fully transparent (0) and fully opaque (1) are excluded, which is useful when you want to ensure partial transparency. The value 0.75 passes.

  3. ageexclusiveMinimum: 0 means age must be at least 1 (since it is an integer), and maximum: 150 sets an inclusive upper bound. The value 30 passes.

Draft Compatibility

The behavior of exclusive bounds changed significantly between JSON Schema drafts:

Draft 4:

{
  "minimum": 0,
  "exclusiveMinimum": true
}

In Draft 4, exclusiveMinimum was a boolean modifier that made the minimum value exclusive.

Draft 6+ (including 2020-12):

{
  "exclusiveMinimum": 0
}

Starting from Draft 6, exclusiveMinimum became a numeric keyword that replaces minimum entirely. This is cleaner and less error-prone.

When to Use Exclusive Bounds

  • Physical constraints: temperatures above absolute zero, speeds below the speed of light.
  • Mathematical ranges: values strictly between 0 and 1 for probabilities and ratios.
  • Business rules: ages greater than zero, quantities that must be positive.
  • Open intervals: any domain where the boundary value itself is invalid or meaningless.

Use Case

Use exclusive bounds in scientific data APIs where boundary values have physical meaning (absolute zero, speed of light), in graphics APIs for opacity and alpha values, and in financial APIs where zero amounts are handled separately from positive transactions.

Try It — JSON Schema Validator

Open full tool