Properties ↔ YAML Converter
A tool for converting Spring Boot's application.properties and application.yml files. Essential for configuration file migration and refactoring!
📄 Properties → YAML
Output will appear here...
💡 Spring Boot Configuration Tips
Properties 장점:
- 간단하고 직관적
- 한 줄에 하나의 설정
- 검색하기 쉬움
YAML 장점:
- 계층 구조가 명확
- 중복 줄임
- 가독성 좋음
주의사항:
- YAML은 들여쓰기에 민감 (스페이스만 사용)
- Properties는 특수문자 이스케이프 필요
- Profile별 파일 분리 권장
Properties vs YAML
Properties Format
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=secret
server.port=8080
YAML Format
spring:
datasource:
url: jdbc:mysql://localhost:3306/mydb
username: root
password: secret
server:
port: 8080
When to Use?
Properties → YAML Conversion
- When migrating projects to YAML
- When you want to see hierarchical structure clearly
- When you want to reduce duplicate prefixes
- When you want to improve readability
YAML → Properties Conversion
- Compatibility with legacy systems
- Preference for simple configuration
- Easier searching and grepping
- Better IDE auto-completion
Real-World Examples
Database Configuration
Properties:
# Database Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=secret123
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
YAML:
# Database Configuration
spring:
datasource:
url: jdbc:mysql://localhost:3306/mydb
username: root
password: secret123
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto: update
show-sql: true
Server & Logging Configuration
Properties:
server.port=8080
server.servlet.context-path=/api
server.compression.enabled=true
logging.level.root=INFO
logging.level.com.example=DEBUG
logging.file.name=logs/application.log
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %msg%n
YAML:
server:
port: 8080
servlet:
context-path: /api
compression:
enabled: true
logging:
level:
root: INFO
com.example: DEBUG
file:
name: logs/application.log
pattern:
console: '%d{yyyy-MM-dd HH:mm:ss} - %msg%n'
Complex Properties
Properties:
spring.kafka.bootstrap-servers=localhost:9092
spring.kafka.consumer.group-id=my-group
spring.kafka.consumer.auto-offset-reset=earliest
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
YAML:
spring:
kafka:
bootstrap-servers: localhost:9092
consumer:
group-id: my-group
auto-offset-reset: earliest
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
Properties vs YAML Comparison
✅ Properties Advantages
- Simplicity: One setting per line
- Easy Search: Easy to find with grep
- Familiarity: Old Java standard
- Special Characters: Easy to escape
✅ YAML Advantages
- Readability: Clear hierarchical structure
- Reduce Duplication: Common prefixes omitted
- Comments: More flexible comments
- Lists: Can express arrays
⚠️ Properties Disadvantages
- Lots of duplication
- Difficult to understand hierarchical structure
- Complex configurations become lengthy
⚠️ YAML Disadvantages
- Sensitive to indentation
- Cannot use tabs (spaces only)
- Difficult to debug parsing errors
Differences in Spring Boot
Profile Usage
Properties:
# application.properties (common)
app.name=MyApp
# application-dev.properties (development)
spring.datasource.url=jdbc:mysql://localhost:3306/dev_db
# application-prod.properties (production)
spring.datasource.url=jdbc:mysql://prod-server:3306/prod_db
YAML (Profile separation in one file):
app:
name: MyApp
---
spring:
config:
activate:
on-profile: dev
datasource:
url: jdbc:mysql://localhost:3306/dev_db
---
spring:
config:
activate:
on-profile: prod
datasource:
url: jdbc:mysql://prod-server:3306/prod_db
List/Array Expression
Properties (using index):
app.servers[0]=server1.example.com
app.servers[1]=server2.example.com
app.servers[2]=server3.example.com
YAML (native array):
app:
servers:
- server1.example.com
- server2.example.com
- server3.example.com
Map Structure
Properties:
app.config.key1=value1
app.config.key2=value2
app.config.key3=value3
YAML:
app:
config:
key1: value1
key2: value2
key3: value3
Usage Tips
1. Gradual Migration
# 1. Backup existing properties
cp application.properties application.properties.bak
# 2. Convert to YAML
# (Use this tool)
# 3. Create application.yml
# 4. Delete properties after testing
2. Profile Separation
# application.yml (common settings only)
app:
name: MyApp
# application-dev.yml (development environment)
# application-prod.yml (production environment)
3. Use Environment Variables for Sensitive Information
spring:
datasource:
password: ${DB_PASSWORD} # Use environment variable
4. Utilize IDE Plugins
- IntelliJ IDEA: Spring Boot support
- VS Code: Spring Boot Extension Pack
- Utilize auto-completion and validation features
Precautions
When Writing YAML
# ❌ Wrong example (using tab)
spring:
datasource: # Using tab - Error!
# ✅ Correct example (using spaces)
spring:
datasource: # 2 spaces
Special Character Handling
Properties:
# Escape special characters with backslash
app.message=Hello\nWorld
app.path=C:\\Users\\Example
YAML:
# Wrap with quotes
app:
message: "Hello\nWorld"
path: "C:\\Users\\Example"
Numbers and Booleans
Properties:
server.port=8080
app.enabled=true
YAML (automatic type conversion):
server:
port: 8080 # Recognized as number
port: "8080" # Keep as string
app:
enabled: true # boolean
enabled: "true" # string
Troubleshooting
Errors After Conversion
-
Check YAML Indentation
- Use 2 spaces
- Check for no tab characters
-
Check Special Characters
- Wrap
:,#,@, etc. with quotes
- Wrap
-
Check Types
- Verify numbers and booleans are converted as intended
-
Check Profile Settings
spring.profiles.activeconfiguration
Related Tools
- JSON Formatter - JSON formatting
- CSV JSON Converter - CSV-JSON conversion
- Text Diff - Compare configuration files
Additional Resources
Best Practices
1. Separate by Environment
application.yml # Common settings
application-dev.yml # Development environment
application-test.yml # Test environment
application-prod.yml # Production environment
2. Externalize Sensitive Information
spring:
datasource:
password: ${DB_PASSWORD:defaultPassword}
3. Use Comments
# Database Configuration
# Separate configuration needed in production environment
spring:
datasource:
url: jdbc:mysql://localhost:3306/mydb
4. Consistent Naming
# Kebab case recommended
spring:
data-source: # ✅
driver-class-name: ...
# Avoid camel case
spring:
dataSource: # ❌
driverClassName: ...