JSON Schema Number Constraints — minimum, maximum, multipleOf

Learn how to refine number and integer types with minimum, maximum, exclusiveMinimum, and multipleOf after generating a JSON Schema from sample data.

Basic Types

Detailed Explanation

Refining Number Types in Generated Schemas

When the generator encounters a numeric value like 42 or 19.99, it emits "type": "integer" or "type": "number" respectively. To enforce business rules you need additional keywords.

Number Keywords at a Glance

Keyword Effect
minimum Value must be >= this number
maximum Value must be <= this number
exclusiveMinimum Value must be > this number
exclusiveMaximum Value must be < this number
multipleOf Value must be an exact multiple

Example: Price Validation

A generated schema might start as:

{ "price": { "type": "number" } }

Refined for an e-commerce API:

{
  "price": {
    "type": "number",
    "minimum": 0,
    "exclusiveMinimum": 0,
    "maximum": 999999.99,
    "multipleOf": 0.01
  }
}

Here exclusiveMinimum: 0 rejects free items (price must be positive), maximum caps the price, and multipleOf: 0.01 ensures two-decimal precision — matching typical currency formats.

Integer vs. Number

JSON Schema distinguishes "integer" (whole numbers only) from "number" (any numeric value including decimals). The generator picks "integer" when the sample value has no fractional part. If your field can accept decimals in production, change the type to "number" after generation.

Combining with Other Keywords

Number constraints compose naturally with enum (e.g., allow only [1, 2, 3]), oneOf (different ranges for different contexts), and if/then (conditional ranges). This flexibility makes JSON Schema number validation powerful enough for financial, scientific, and configuration use cases alike.

Always review generated number types against your real data range to avoid silently accepting out-of-bound values.

Use Case

Use number constraints for pricing fields, quantity limits, pagination parameters, rating scores, or any numeric API input that must fall within a defined range.

Try It — JSON Schema Generator

Open full tool