YAML ↔ JSON Converter API
Convert YAML to JSON and JSON to YAML online. Bidirectional, validated conversion with error locations. Free, fast, 100% client-side.
The YAML ↔ JSON Converter is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/yaml-json — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
mode | "yaml-to-json" | "json-to-yaml" | required | Conversion direction: YAML to JSON, or JSON to YAML. |
input | string | required | The YAML or JSON text to convert. |
indent | "2" | "4" | required | Number of spaces per indentation level in the output. |
Response
| Field | Type | Required | Description |
|---|---|---|---|
output | string | required | The converted document. Empty when the input is invalid. |
valid | boolean | required | Whether the input parsed successfully. |
error | unknown | required | Parse error message when invalid. |
errorLine | unknown | required | 1-based line of the parse error when invalid. |
errorColumn | unknown | required | 1-based column of the parse error when invalid. |
Example request
curl -X POST https://dot.tools/api/tools/yaml-json \
-H 'Content-Type: application/json' \
-d '{
"mode": "yaml-to-json",
"indent": "2",
"input": "name: dot.tools\nversion: 2.0.0\nprivate: true\ntools:\n - json-formatter\n - xml-formatter\n - yaml-json\nmeta:\n clientSide: true\n category: format"
}'Sample response
{
"ok": true,
"result": {
"output": "{\n \"name\": \"dot.tools\",\n \"version\": \"2.0.0\",\n \"private\": true,\n \"tools\": [\n \"json-formatter\",\n \"xml-formatter\",\n \"yaml-json\"\n ],\n \"meta\": {\n \"clientSide\": true,\n \"category\": \"format\"\n }\n}",
"valid": true,
"error": null,
"errorLine": null,
"errorColumn": null
}
}Use the free YAML ↔ JSON Converter in your browser, read the YAML ↔ JSON Converter guide, or import the full OpenAPI specification.