Generate a Spring Boot @ConfigurationProperties POJO

Convert an application configuration JSON or YAML payload into a Spring Boot @ConfigurationProperties class with nested groups, lists, and validation annotations.

Real-world

Detailed Explanation

Spring Boot @ConfigurationProperties from JSON

Spring Boot's @ConfigurationProperties binds external configuration (application.yml, environment variables, JSON config servers) to a strongly-typed Java POJO. Even when your config lives in YAML, it is structurally equivalent to JSON, so this generator works directly.

Example Configuration JSON

{
  "app": {
    "name": "OrderService",
    "version": "2.4.1",
    "timeout_seconds": 30,
    "feature_flags": {
      "use_new_payments": true,
      "enable_audit_log": false
    },
    "database": {
      "url": "jdbc:postgresql://localhost:5432/orders",
      "pool_size": 20
    },
    "trusted_origins": [
      "https://app.example.com",
      "https://admin.example.com"
    ]
  }
}

Generated POJO

After generation, wire it up with Spring annotations:

package com.example.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

@ConfigurationProperties(prefix = "app")
public class AppProperties {
    private String name;
    private String version;

    @JsonProperty("timeout_seconds")
    private Integer timeoutSeconds;

    @JsonProperty("feature_flags")
    private Map<String, Boolean> featureFlags;

    private Database database;

    @JsonProperty("trusted_origins")
    private List<String> trustedOrigins;
    // accessors
}

public class Database {
    private String url;

    @JsonProperty("pool_size")
    private Integer poolSize;
    // accessors
}

Equivalent application.yml

app:
  name: OrderService
  version: 2.4.1
  timeout-seconds: 30
  feature-flags:
    use-new-payments: true
    enable-audit-log: false
  database:
    url: jdbc:postgresql://localhost:5432/orders
    pool-size: 20
  trusted-origins:
    - https://app.example.com
    - https://admin.example.com

Note: Spring's @ConfigurationProperties binder accepts kebab-case in YAML and maps it to camelCase Java fields automatically — the @JsonProperty annotations are only needed if you also deserialize the same POJO from JSON.

Enabling the Binder

In your main application class:

@SpringBootApplication
@EnableConfigurationProperties(AppProperties.class)
public class App {
    public static void main(String[] args) { SpringApplication.run(App.class, args); }
}

Adding Validation

Add JSR-380 (jakarta.validation) annotations to enforce config correctness at startup:

@NotBlank
private String name;

@Min(1) @Max(300)
private Integer timeoutSeconds;

@NotEmpty
private List<String> trustedOrigins;

Combine with @Validated on the class to fail fast at startup if any constraint is violated.

Records for Configuration

Spring Boot 3 supports records for @ConfigurationProperties:

@ConfigurationProperties(prefix = "app")
public record AppProperties(String name, String version,
                            Integer timeoutSeconds, Database database) {}

Records make the configuration immutable, which is the right default for app-startup config.

Use Case

Spring Boot microservices typically have a top-level @ConfigurationProperties class per concern (database, messaging, feature flags, third-party API keys). Generating the POJO from sample JSON config saves the tedious step of hand-translating the YAML structure.

Try It — JSON to Java

Open full tool