Converting application.properties to YAML for Spring Boot

Spring Boot supports two configuration file formats: the flat key-value application.properties format and the hierarchical application.yml YAML format. Both work equally well, but YAML offers significantly better readability for complex configurations with multiple nested properties. Converting from application.properties to YAML is straightforward — and this guide shows you every method to do it.

Why Convert application.properties to YAML?

The application.properties format uses flat dot-notation keys that repeat common prefixes on every line. A database configuration block with five properties repeats spring.datasource five times. The equivalent YAML groups these under a single spring.datasource: block with child keys indented beneath it — immediately cleaner and easier to scan. For complex Spring Boot applications with many configuration groups, the difference becomes dramatic.

application.properties vs application.yml: Side-by-Side Example

application.properties:

spring.datasource.url=jdbc:postgresql://localhost:5432/mydb
spring.datasource.username=admin
spring.datasource.password=secret
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
server.port=8080
server.servlet.context-path=/api

application.yml (equivalent):

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/mydb
    username: admin
    password: secret
    driver-class-name: org.postgresql.Driver
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true

server:
  port: 8080
  servlet:
    context-path: /api

The YAML version removes repetition entirely. Common prefixes are grouped hierarchically, making the config file structure self-documenting.

How to Convert application.properties to YAML Online

Format Pilot’s online converter can assist with format conversion tasks. For Spring Boot-specific properties-to-YAML conversion, the process is: paste your properties content, use the tool to restructure the flat keys into nested YAML hierarchy, then validate the output structure before using in your project.

Convert application.properties to YAML Manually

The conversion rules are consistent and learnable. Each dot in a property key represents a new indentation level in YAML. The value after the equals sign becomes the YAML value after the colon. Multiple keys sharing the same prefix are grouped under that prefix as a YAML block. Here is the step-by-step process:

  1. Identify all unique top-level prefixes (the part before the first dot)
  2. Group all properties under each prefix
  3. For each group, create a YAML key at the top level
  4. Add child keys indented by 2 spaces for each additional dot level
  5. Replace the = sign with :
  6. Quote string values that contain special characters like colons

Using Spring Boot Profiles with YAML

One advantage of YAML for Spring Boot configuration is multi-document support. A single application.yml file can contain configurations for multiple profiles separated by ---:

spring:
  profiles:
    active: dev

---
spring:
  config:
    activate:
      on-profile: dev
  datasource:
    url: jdbc:h2:mem:devdb

---
spring:
  config:
    activate:
      on-profile: prod
  datasource:
    url: jdbc:postgresql://prod-db:5432/myapp

With application.properties, you need separate application-dev.properties and application-prod.properties files. YAML consolidates multiple profiles into one file.

Frequently Asked Questions

Can I use both application.properties and application.yml in the same project?

You can have both files, but it is not recommended. Spring Boot loads both if present, which can cause confusion about which value wins when the same property is defined in both. Stick to one format. If migrating, delete the application.properties file once you have verified the YAML equivalent is correct.

Do string values need quotes in application.yml?

Most string values do not need quotes in YAML. However, values containing colons, leading/trailing spaces, special characters like # (which starts a comment), or values that look like other types (like true, null, or 1234) should be quoted to prevent misinterpretation. Database URLs with colons in them should always be quoted.

Is application.yml faster than application.properties in Spring Boot?

Performance is identical. Spring Boot parses both formats at startup and loads properties into the same internal representation. The choice between them is purely a developer experience decision — YAML is more readable and maintainable, properties is simpler for very flat configurations.