YAML Validator

Validate YAML strings and convert to JSON.

POST 1 credit /v1/yaml-validate
curl -X POST "https://devtools.toolkitapi.io/v1/yaml-validate" \
  -H "Content-Type: application/json" \
  -d '{"data": "name: Alice\nage: 30\ntags:\n  - dev\n  - ops"}'
import httpx

resp = httpx.post(
    "https://devtools.toolkitapi.io/v1/yaml-validate",
    json={"data": "name: Alice\nage: 30\ntags:\n  - dev\n  - ops"},
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/yaml-validate", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"data": "name: Alice\nage: 30\ntags:\n  - dev\n  - ops"}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "valid": true,
  "as_json": {
    "name": "Alice",
    "age": 30,
    "tags": ["dev", "ops"]
  }
}

Try It Live

Live Demo

Description

Validate YAML strings and convert to JSON.

How to Use

1

1. Send a POST request with a `data` field containing the raw YAML string.

2

2. If `valid` is `true`, the `as_json` field contains the parsed YAML as a JSON-compatible object.

3

3. If `valid` is `false`, the `error` field describes the syntax problem.

About This Tool

YAML Validator checks whether a given string is valid YAML. When valid, it returns the parsed data as a JSON object — handy for YAML-to-JSON conversion. When invalid, it returns the parse error.

Why Use This Tool

Frequently Asked Questions

Does it support multi-document YAML?
The validator parses the first YAML document in the stream using `safe_load`. Multi-document streams (separated by `---`) will only return the first document.
Can I use this for YAML-to-JSON conversion?
Yes. When validation succeeds, the `as_json` field is a fully JSON-compatible representation of your YAML data.

Start using YAML Validator now

Get your free API key and make your first request in under a minute.