
JSON to YAML Converter API
Development
Convert JSON to YAML and YAML to JSON as you type, with indentation and key-sorting options, errors that point to the line and column, and copy or download.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
120 requests per minute
Endpoints
1 endpoint available
Overview
Convert JSON to YAML or YAML to JSON. Send the text and the direction, and get the converted text back along with any warnings.
Behavior
- json-to-yaml: the JSON must be strictly valid (no comments, trailing commas or single quotes). Lines are not wrapped. Integers larger than 9,007,199,254,740,991 are rounded and a warning says so; quote them as strings to keep every digit.
- yaml-to-json: a file with several documents (separated by ---) becomes a JSON array with one item per document, and a warning says so. The values .inf and .nan become null with a warning. Alias expansion is capped at 100.
sortKeyssorts object keys alphabetically at every level. Arrays keep their order.
Errors
Invalid input returns a 400. The error message describes the first problem, and details holds its line and column (both 1-based) when they are known.
Notes
textis limited to 500,000 characters.jsonIndentapplies to YAML to JSON output andyamlIndentto JSON to YAML output.
Endpoints
POST
https://opentools.ca/api/v1/tools/json-yaml-converterConvert JSON to YAML or YAML to JSON
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| direction | string Enum: json-to-yaml, yaml-to-json | Required | Which way to convert |
| text | string | Required | The JSON or YAML to convert, 1-500,000 characters |
| jsonIndent | number or string | Optional | Indentation of JSON output: 2, 4, 0 (minified) or "tab"Default: 2 |
| yamlIndent | number | Optional | Indentation of YAML output: 2 or 4Default: 2 |
| sortKeys | boolean | Optional | Sort object keys alphabeticallyDefault: false |
Response Example
{
"success": true,
"direction": "json-to-yaml",
"output": "name: app\nports:\n - 80\n - 443\ndebug: false\n",
"warnings": []
}Error Codes
400
Bad Request - Invalid options, or JSON or YAML that does not parse (details has the line and column)401
Unauthorized - Invalid or missing API key403
Forbidden - API key is inactive or expired, or the request IP is not allowed429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
curl -X POST https://opentools.ca/api/v1/tools/json-yaml-converter \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"direction": "json-to-yaml",
"text": "{\"name\":\"app\",\"ports\":[80,443],\"debug\":false}"
}'Rather use it in your browser? Open the JSON to YAML Converter