default keyword specifies a default JSON value that can be used when an instance value is not provided. It is commonly used in configuration schemas, form generation, and API documentation.
Syntax
The value ofdefault can be of any type, including null. There are no restrictions on the value.
Purpose
Thedefault keyword is a metadata annotation that:
- Supplies a default value when no value is provided
- Helps tools generate forms with pre-filled values
- Documents the recommended or typical value for a field
- Can be used by implementations to fill in missing values
- Has no effect on validation (it is purely informational)
- Should be a valid value against the associated schema (recommended)
Behavior
When multiple occurrences of thedefault keyword are applicable to a single sub-instance, implementations should remove duplicates.
Implementations may use the default value as an additional example for documentation purposes.
Examples
Basic Default Values
String Default
Boolean Default
Object with Default Values
Array Default
Null Default
Configuration Schema
Pagination Parameters
Theme Configuration
Feature Flags
Retry Configuration
Search Options
Best Practices
Use Valid Defaults
Ensure default values validate against the schema:Choose Safe Defaults
Select defaults that are safe for production use:Document Default Behavior
Combinedefault with description to explain the default choice: