YAML to JSON Converter (and JSON to YAML)
Convert YAML to JSON or JSON to YAML in one endpoint, with multi-document support and syntax errors reported with line and column.
Result
Press “Run” to see the result.
Send yaml to get JSON, or json to get YAML; the direction is picked automatically and can be forced with to=json or to=yaml. YAML can also be posted as a raw text body (for example text/yaml) with to=json.
YAML to JSON returns valid, the parsed value in json and the number of documents; files with several documents separated by --- return an array. Invalid YAML returns valid: false with an error message, line and column instead of an HTTP error.
JSON to YAML accepts a JSON value or JSON string in json and returns the YAML text in yaml; indent sets the indentation (1 to 8, default 2). The request body is limited to 5 MB.
Use this in your code
curl -X POST "https://apibox.io.vn/v1/yaml" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"yaml":"name: APIBox\nversion: 1\nfeatures:\n - html\n - json\nenabled: true"}'const res = await fetch('https://apibox.io.vn/v1/yaml', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"yaml": "name: APIBox\nversion: 1\nfeatures:\n - html\n - json\nenabled: true"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/yaml",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"yaml": "name: APIBox\nversion: 1\nfeatures:\n - html\n - json\nenabled: true"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/yaml');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"yaml":"name: APIBox\\nversion: 1\\nfeatures:\\n - html\\n - json\\nenabled: true"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));API documentation → Get a free API key
FAQ
How do I choose the conversion direction?
Send yaml to get JSON, or json to get YAML. To be explicit, add to=json or to=yaml.
Are multi-document YAML files supported?
Yes. Documents separated by --- are returned as an array in json, and documents gives their count.
How are YAML syntax errors reported?
The response is valid: false with error.message, error.line and error.column.