# YAML ↔ JSON Converter > Convert between YAML and JSON formats instantly. Paste YAML to get JSON or JSON to get YAML. **Category:** Dev **Keywords:** yaml, json, converter, data format, serialize, parse, config, configuration, transform, developer tools **URL:** https://complete.tools/yaml-json-converter ## How it works The conversion process follows these steps: **Format Detection:** - If input starts with { or [ and parses as valid JSON, treat as JSON - Otherwise, attempt to parse as YAML - Invalid input in both formats returns an error message **JSON to YAML Conversion:** - Remove braces, brackets, and quotation marks - Convert nested objects to indented key-value pairs - Transform arrays to hyphenated list items - Preserve data types (strings, numbers, booleans, null) **YAML to JSON Conversion:** - Add braces around objects and brackets around arrays - Quote all string keys and values - Convert indented structures to nested objects - Maintain array order and data types ## Who should use this - **DevOps engineers** converting between Docker Compose YAML and JSON for API calls - **Backend developers** transforming API responses for configuration file generation - **Kubernetes administrators** debugging YAML manifests by viewing JSON equivalents - **CI/CD pipeline maintainers** switching between GitHub Actions YAML and JSON schemas - **Data engineers** migrating configuration between systems using different formats ## Worked examples **Example 1: Simple object conversion** YAML input: name: John Smith age: 35 active: true JSON output: {"name": "John Smith", "age": 35, "active": true} **Example 2: Nested structure with arrays** JSON input: {"server": {"host": "localhost", "port": 8080}, "features": ["auth", "logging"]} YAML output: server: host: localhost port: 8080 features: - auth - logging **Example 3: Docker Compose snippet** YAML input: services: web: image: nginx:latest ports: - 80:80 JSON output: {"services": {"web": {"image": "nginx:latest", "ports": ["80:80"]}}} ## Limitations - YAML comments are not preserved during conversion because JSON does not support comments - YAML anchors and aliases (&anchor, *alias) are resolved and not preserved as references - Multi-document YAML files (separated by ---) convert only the first document - YAML custom tags (!!type) may not convert correctly to JSON - Very large files over 1MB may cause browser performance issues - Binary data in YAML must be base64-encoded for JSON compatibility ## FAQs ** **Q:** Why are my YAML comments missing in the JSON output?** **A:** JSON specification does not support comments. When converting YAML to JSON, all comments are stripped because there is no valid JSON syntax to represent them. ** **Q:** Can I convert JSON with trailing commas?** **A:** Strict JSON does not allow trailing commas. This tool uses a lenient parser that accepts trailing commas, but the output will always be valid strict JSON without them. ** **Q:** Why does my YAML have quotes around strings in the JSON output?** **A:** JSON requires all string values and keys to be enclosed in double quotes. YAML allows unquoted strings, but JSON does not support this syntax. ** **Q:** Is my data sent to a server?** **A:** No. All conversion happens locally in your browser using JavaScript. Your data never leaves your device, making this tool safe for sensitive configuration files. --- *Generated from [complete.tools/yaml-json-converter](https://complete.tools/yaml-json-converter)*