A Spring Boot application that converts Java properties files to YAML format. This tool provides both REST API endpoints and supports various input formats including JSON, plain text, and file uploads.
- 🔄 Convert properties to YAML format
- 📝 Multiple input formats: JSON, plain text, and file upload
- 🌳 Automatically handles nested properties with dot notation
- 📊 Supports array notation (e.g.,
items[0].name) - 🗺️ Supports map keys with special characters (e.g.,
[/**]) - 🎯 Smart type detection (numbers, booleans, strings)
- 📥 Download converted YAML files
- 🧪 Comprehensive test coverage
- ✅ CI/CD with GitHub Actions
- Java 17 or higher
- Maven 3.6+
- Spring Boot 3.2.0
git clone https://github.com/gridatek/properties2yaml.git
cd properties2yamlmvn clean packagemvn spring-boot:runOr run the JAR file:
java -jar target/properties2yaml-1.0.0-SNAPSHOT.jarThe application will start on http://localhost:8080
POST /api/convert
Convert properties content sent as JSON.
Request:
curl -X POST http://localhost:8080/api/convert \
-H "Content-Type: application/json" \
-d '{
"propertiesContent": "server.port=8080\nserver.address=localhost"
}'Response:
{
"success": true,
"yamlContent": "server:\n port: 8080\n address: localhost\n",
"error": null
}POST /api/convert/text
Convert properties content sent as plain text.
Request:
curl -X POST http://localhost:8080/api/convert/text \
-H "Content-Type: text/plain" \
-d "server.port=8080
server.address=localhost"Response:
server:
port: 8080
address: localhostPOST /api/convert/file
Upload a properties file for conversion.
Request:
curl -X POST http://localhost:8080/api/convert/file \
-F "file=@application.properties"Response:
{
"success": true,
"yamlContent": "server:\n port: 8080\n address: localhost\n",
"error": null
}POST /api/convert/file/download
Upload a properties file and download the YAML result.
Request:
curl -X POST http://localhost:8080/api/convert/file/download \
-F "file=@application.properties" \
-O -JThis will download a file named application.yaml with the converted content.
Input:
server.port=8080
server.address=localhost
app.name=MyApplicationOutput:
server:
port: 8080
address: localhost
app:
name: MyApplicationInput:
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=secret
spring.jpa.hibernate.ddl-auto=updateOutput:
spring:
datasource:
url: jdbc:mysql://localhost:3306/mydb
username: root
password: secret
jpa:
hibernate:
ddl-auto: updateInput:
items[0].name=Item 1
items[0].price=10.99
items[1].name=Item 2
items[1].price=20.50Output:
items:
- name: Item 1
price: 10.99
- name: Item 2
price: 20.5Input:
spring.cloud.gateway.routes[0].id=user-service
spring.cloud.gateway.routes[0].uri=lb://user-service
spring.cloud.gateway.routes[0].predicates[0]=Path=/api/users/**
spring.cloud.gateway.globalcors.cors-configurations.[/**].allowed-origins=*
spring.cloud.gateway.globalcors.cors-configurations.[/**].allowed-methods=GET,POSTOutput:
spring:
cloud:
gateway:
routes:
- id: user-service
uri: lb://user-service
predicates:
- Path=/api/users/**
globalcors:
cors-configurations:
"[/**]":
allowed-origins: '*'
allowed-methods: GET,POSTThe converter automatically detects and converts data types:
- Numbers:
port=8080→port: 8080 - Booleans:
enabled=true→enabled: true - Strings:
name=MyApp→name: MyApp
mvn clean compilemvn testmvn verifymvn test jacoco:reportThe coverage report will be available at target/site/jacoco/index.html
mvn packageThis creates an executable JAR file in the target/ directory.
The project includes comprehensive tests:
- Unit Tests: Test individual components and conversion logic
- Integration Tests: Test REST API endpoints and file handling
- Complex Test Cases: Test real-world configurations (Spring Boot, microservices, etc.)
Run all tests:
mvn clean verifyThe project uses GitHub Actions for continuous integration:
- Build and Test: Runs on Java 17 and 21
- Code Quality: Generates test coverage reports
- Integration Tests: Validates API endpoints
- Dependency Check: Monitors for dependency updates
View the CI workflow for details.
properties2yaml/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/converter/properties2yaml/
│ │ │ ├── controller/ # REST controllers
│ │ │ ├── model/ # Request/Response models
│ │ │ ├── service/ # Conversion service
│ │ │ └── Properties2YamlApplication.java
│ │ └── resources/
│ │ └── application.properties
│ └── test/
│ └── java/
│ └── com/converter/properties2yaml/
│ ├── integration/ # Integration tests
│ └── service/ # Unit tests
├── .github/
│ └── workflows/
│ └── ci.yml # CI/CD configuration
├── pom.xml # Maven configuration
└── README.md
- Spring Boot 3.2.0: Application framework
- SnakeYAML 2.2: YAML processing
- JUnit 5: Testing framework
- Maven: Build tool
- JaCoCo: Code coverage
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Spring Boot
- YAML processing by SnakeYAML
For issues, questions, or contributions, please visit the GitHub repository.