What does the Java Properties to YAML Converter do?
The Java Properties to YAML Converter parses Java .properties files and Spring Boot application.properties configurations and converts them into structured, hierarchical application.yml documents. It transforms dot-delimited property paths and array indices into nested YAML tree mappings while automatically casting numbers, booleans, and multiline continuations.
Core Concepts
Understanding Java properties to YAML conversion mechanics:
- Dot-Notation Path Hierarchy: Splits dot-delimited property keys (e.g.
spring.datasource.url) into indented YAML object blocks. - Array & List Indexing: Converts numerical bracket notations (such as
app.cors.allowed-origins[0]) into native YAML sequence items (- https://example.com). - Primitive Type Casting: Automatically detects numbers (e.g.
server.port=8080), booleans (true/false), and unescapes standard Java property escape codes (\n,\t,\:,\=).
How to use the tool?
- Paste Properties: Enter or paste your
.propertiescontent into the input box or click Sample. - Configure Indentation: Select your desired YAML indentation spacing (2 spaces, 4 spaces, or custom indentation width).
- Copy & Export: Converts reactively in real time. Click Copy or Download to save your
application.ymlfile.
Related Developer Utilities
If you work with Java properties, Spring Boot configurations, and YAML formatting, explore these complementary tools:
- YAML to Java Properties Converter: Flatten Spring Boot YAML files back into standard Java properties.
- YAML Formatter & Beautifier: Format and re-indent YAML configuration files.
- YAML Syntax Validator: Validate YAML syntax and check line/column offsets.
- YAML to JSON Converter: Convert YAML manifests into JSON payloads.
REST API Integration
blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/yaml/properties-to-yaml) to programmatically convert Java .properties and Spring Boot application.properties into formatted application.yml files.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String / Object | Java properties content with dot notation or parsed key-value object (aliases: rawProperties, properties, data, payload, input, text). |
"spring.datasource.url=jdbc:h2:mem\nserver.port=8080" |
indent |
Number | Indentation spaces: 2 (default) or 4 (aliases: spaces, space). |
2 |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/yaml/properties-to-yaml \
-H "Content-Type: application/json" \
-d '{
"rawText": "spring.datasource.url=jdbc:postgresql://localhost:5432/mydb\nserver.port=8080\napp.cors.allowed-origins[0]=https://blueutils.com",
"indent": 2
}'Python
import requests
url = "https://blueutils.com/api/yaml/properties-to-yaml"
payload = {
"rawText": "spring.datasource.url=jdbc:postgresql://localhost:5432/mydb\nserver.port=8080\napp.cors.allowed-origins[0]=https://blueutils.com",
"indent": 2
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = """
{
"rawText": "spring.datasource.url=jdbc:postgresql://localhost:5432/mydb\\nserver.port=8080",
"indent": 2
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/yaml/properties-to-yaml"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether the conversion succeeded. | true |
propertyCount |
Number | Count of processed key-value properties. | 2 |
converted |
String | Formatted YAML string. | "spring:\n datasource:\n url: ..." |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"propertyCount": 3,
"converted": "spring:\n datasource:\n url: jdbc:postgresql://localhost:5432/mydb\nserver:\n port: 8080\napp:\n cors:\n allowed-origins:\n - https://blueutils.com\n"
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "No valid property definitions found."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API to convert properties to YAML?
Integrating the Properties to YAML API into Spring Boot migration scripts or CI/CD modernization tooling provides significant advantages:
- Rapid Script Validation: Converts legacy flat microservice property files into clean, hierarchical YAML without manual tree editing.
- Optimized Token Efficiency for AI Agents: LLMs often misalign indentation when restructuring nested property files. Invoking the API parses paths into valid YAML structures deterministically.
- Deterministic Accuracy Without Hallucinations: Ensures 100% accurate tree nesting, bracket list conversion, and type parsing.
Native Usage
How to convert Java properties to YAML locally in terminal environments or scripts:
Windows (CMD / PowerShell)
# Convert properties to YAML using Python in PowerShell
python -c "
import sys, yaml
data = {}
with open('application.properties') as f:
for line in f:
line = line.strip()
if not line or line.startswith('#'): continue
k, v = line.split('=', 1)
parts = k.split('.')
curr = data
for p in parts[:-1]: curr = curr.setdefault(p, {})
curr[parts[-1]] = v
print(yaml.dump(data, default_flow_style=False))
"Linux / Unix (Bash)
# Convert properties to YAML using Python in Linux
python3 -c "
import sys, yaml
data = {}
for line in open('application.properties'):
line = line.strip()
if not line or line.startswith('#'): continue
k, v = line.split('=', 1)
parts = k.split('.')
curr = data
for p in parts[:-1]: curr = curr.setdefault(p, {})
curr[parts[-1]] = v
print(yaml.dump(data, default_flow_style=False))
"Python
Using Python yaml:
import yaml
data = {}
with open('application.properties', 'r') as f:
for line in f:
line = line.strip()
if not line or line.startswith(('#', '!')):
continue
key, val = line.split('=', 1) if '=' in line else line.split(':', 1)
parts = key.strip().split('.')
curr = data
for part in parts[:-1]:
curr = curr.setdefault(part, {})
curr[parts[-1]] = val.strip()
print(yaml.dump(data, sort_keys=False))Java
Using Java and SnakeYAML:
import org.yaml.snakeyaml.Yaml;
import java.io.FileInputStream;
import java.util.*;
public class PropertiesToYamlExample {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
try (FileInputStream in = new FileInputStream("application.properties")) {
props.load(in);
}
Map<String, Object> map = new LinkedHashMap<>();
for (String name : props.stringPropertyNames()) {
map.put(name, props.getProperty(name));
}
Yaml yaml = new Yaml();
System.out.println(yaml.dump(map));
}
}