Skip to content

Free · Data & Config · runs in your browser

Spring Boot YAML Converter

By Nayeem, Software Developer of fastsavemedia.comLast reviewed

What Is application.yml in Spring Boot?

In Spring Boot, externalized configuration is the mechanism that lets you separate environment-specific values — database URLs, ports, credentials, feature flags — from your compiled Java code. The two canonical formats are application.properties (flat key=value pairs) and application.yml (hierarchical YAML). Both live on the classpath, typically under src/main/resources, and are loaded automatically by Spring Boot at startup through the Environment abstraction.

YAML's nested structure mirrors the namespaces of Spring Boot configuration keys. A property like spring.datasource.hikari.maximum-pool-size becomes a clean indented tree, which is much easier to scan when you have dozens or hundreds of keys for a real-world microservice. That's why the YAML format has become the de-facto standard in Spring Boot 3.x, Spring Cloud, Spring Cloud Kubernetes and Spring for GraphQL projects.

Properties vs YAML in Spring Boot

Aspectapplication.propertiesapplication.yml
SyntaxFlat key=valueNested, indentation-based
Readability for deep hierarchiesVerbose, repetitive prefixesClean, grouped, scannable
Lists / arraysIndexed keys (servers[0]=…)Native YAML lists
Multi-document / profilesSeparate application-{profile}.properties onlyProfile files and--- document separators in one file
Comments##
Tooling supportExcellent everywhereExcellent (IDE plugins, schemas)
Risk of bugsLow — flat keysIndentation errors break the file
Recommended forTiny apps, legacy projectsMicroservices, cloud-native apps

Advantages of YAML

  • Hierarchy mirrors namespaces — spring.*, management.* and your own @ConfigurationProperties beans group naturally.
  • First-class lists and maps — perfect for spring.kafka.bootstrap-servers, CORS allowed origins, scheduler cron lists.
  • Multi-document profiles — define all profile overrides in a single application.yml with --- separators and spring.config.activate.on-profile.
  • Better diffs in code review — adding a single nested key produces a one-line diff instead of a long prefix.
  • Ecosystem alignment — Kubernetes manifests, Helm charts, GitHub Actions and Docker Compose are all YAML, so your operators read one syntax end-to-end.

When To Use application.properties

Properties files still make sense in a handful of cases: legacy Spring 2.x projects, internal tools where the config is 5–10 lines and never grows, IDE-driven quick experiments, and override files like application-test.properties that ship inside a JAR for repeatable test runs. Outside those cases, YAML wins for any service that will be promoted across dev → test → staging → prod.

Spring Boot Configuration Best Practices

  • Keep secrets out of source control. Use environment variables, Spring Cloud Config, HashiCorp Vault, AWS Secrets Manager, or Kubernetes Secrets mounted as files.
  • Use @ConfigurationProperties for typed binding instead of scattering @Value across the codebase.
  • Pin a default profile (spring.profiles.default: local) so misconfigured environments fail loudly.
  • Externalize per-environment values via --spring.config.location or SPRING_CONFIG_IMPORT rather than baking them in the JAR.
  • Always set HikariCP pool size, connection timeout and max lifetime explicitly in production.
  • Enable actuator health, info and metrics endpoints, then expose only what your platform consumes.
  • Set logging.level per package; never ship DEBUG on the root logger to production.
  • Validate config at startup with @Validated on your properties beans.

Common YAML Mistakes

  • Tabs instead of spaces. YAML forbids tabs for indentation. Use two spaces consistently.
  • Misaligned children. Sibling keys must share the exact same column.
  • Implicit type surprises. Unquoted yes, no, on, off become booleans; quote them if you mean strings.
  • Leading zeros.port: 08080 is parsed as octal in YAML 1.1 — quote numeric strings.
  • Duplicate keys. Two top-level spring: blocks silently overwrite earlier values in many parsers.
  • Multiline scalars. Use | (literal) or > (folded) for embedded SQL, JWT secrets or PEM keys.

Common Spring Boot Configuration Errors

  • spring.database.url — wrong namespace; the correct key is spring.datasource.url.
  • server.servlet.contextPath — camelCase ignored; use server.servlet.context-path.
  • spring.jpa.hibernate.ddlAuto — wrong; use spring.jpa.hibernate.ddl-auto.
  • Forgetting spring.jpa.database-platform when Spring Boot can't auto-detect the dialect.
  • Setting spring.datasource.driver-class-name unnecessarily on Spring Boot 3 — it's auto-detected.
  • Using management.endpoints.web.expose instead of management.endpoints.web.exposure.include.

Spring Boot Configuration Examples

MySQL + HikariCP

spring: datasource: url: jdbc:mysql://localhost:3306/demo?useSSL=false&serverTimezone=UTC username: root password: ${DB_PASSWORD} hikari: maximum-pool-size: 20 minimum-idle: 5 idle-timeout: 30000 connection-timeout: 20000 jpa: hibernate: ddl-auto: validate properties: hibernate: dialect: org.hibernate.dialect.MySQL8Dialect

PostgreSQL

spring: datasource: url: jdbc:postgresql://localhost:5432/demo username: postgres password: ${DB_PASSWORD} jpa: properties: hibernate: dialect: org.hibernate.dialect.PostgreSQLDialect

MongoDB

spring: data: mongodb: uri: mongodb://user:pass@localhost:27017/demo?authSource=admin

Redis

spring: data: redis: host: localhost port: 6379 password: ${REDIS_PASSWORD} timeout: 2000ms lettuce: pool: max-active: 16 max-idle: 8

Kafka

spring: kafka: bootstrap-servers: localhost:9092 consumer: group-id: demo-group auto-offset-reset: earliest key-deserializer: org.apache.kafka.common.serialization.StringDeserializer value-deserializer: org.apache.kafka.common.serialization.StringDeserializer producer: key-serializer: org.apache.kafka.common.serialization.StringSerializer value-serializer: org.apache.kafka.common.serialization.StringSerializer acks: all

RabbitMQ

spring: rabbitmq: host: localhost port: 5672 username: guest password: guest virtual-host: /

OAuth2 Resource Server (JWT)

spring: security: oauth2: resourceserver: jwt: issuer-uri: https://auth.example.com/realms/demo

JWT App-Level Config

app: jwt: secret: ${JWT_SECRET} expiration-ms: 3600000 issuer: my-service

Production Configuration Checklist

  • ✅ Externalize all secrets via env vars or a secrets manager.
  • ✅ Set explicit HikariCP pool, timeout and max-lifetime values.
  • ✅ Enable spring.jpa.open-in-view: false in production.
  • ✅ Expose only required actuator endpoints; protect them with Spring Security.
  • ✅ Configure structured JSON logging for log aggregation (ELK / Loki / Datadog).
  • ✅ Set server.shutdown: graceful and a sane spring.lifecycle.timeout-per-shutdown-phase.
  • ✅ Set server.tomcat.max-threads based on benchmarks, not defaults.
  • ✅ Pin spring.jpa.hibernate.ddl-auto to validate or none; never update in prod.
  • ✅ Enable HTTP/2 and gzip compression where applicable.
  • ✅ Add health, liveness and readiness probes for Kubernetes.

Frequently Asked Questions

Frequently asked questions

What is application.yml in Spring Boot?

application.yml is the YAML form of Spring Boot's externalized configuration. It uses nested keys and indentation instead of dot-separated properties, making complex configuration easier to read and maintain.

Can Spring Boot use both application.properties and application.yml?

Yes. Spring Boot loads both formats from the classpath. If both exist with the same key, the .properties file generally takes precedence when loaded later, but mixing formats is discouraged.

How do I switch profiles in application.yml?

Use spring.profiles.active: dev to activate a profile, and create profile-specific files such as application-dev.yml, application-prod.yml, etc.

Is the Spring Boot YAML Converter free?

Yes, the converter is 100% free, requires no signup, and runs entirely in your browser — your configuration never leaves your machine.

Does this tool validate Spring Boot configuration?

Yes. It detects duplicate keys, YAML indentation/syntax errors, common Spring Boot key mistakes (like spring.database vs spring.datasource), and suggests fixes.