YAML to JSON Converter: Convert YAML Config Files to JSON
Convert YAML configuration files to JSON, with full support for anchors, aliases, multi-document files, and all YAML 1.2 data types. Instant browser-based conversion.
Try the free online tool
Runs entirely in your browser — no signup, no uploads.
YAML is excellent for human-authored configuration files because of its clean, whitespace-based syntax and support for comments. But many APIs, SDKs, and configuration processing tools expect JSON input. Converting between the two formats is a common task for developers working in DevOps, cloud infrastructure, or application configuration management, where YAML configs need to be passed to JSON-based APIs or stored in JSON-only systems.
YAML is a superset of JSON, meaning that valid JSON is also valid YAML. However, YAML has additional features not present in JSON: anchors and aliases (for reuse), multi-document files, block and flow styles for collections, and a richer set of native types. When converting to JSON, these features need to be resolved into the simpler JSON data model.
This converter handles the full YAML 1.2 specification, resolving anchors and aliases before serializing to JSON, converting YAML-specific types like timestamps and binary data to JSON-compatible representations, and handling multi-document YAML files by outputting a JSON array of documents.
What Is YAML and How Does It Relate to JSON?
YAML stands for 'YAML Ain't Markup Language', a recursive acronym reflecting its philosophy of being a data format rather than a markup language. YAML was designed for human readability: it uses indentation for structure instead of braces, allows unquoted strings in most cases, and supports comments with the # character. These features make it popular for configuration files that humans write and maintain.
JSON (JavaScript Object Notation) was designed for machine-to-machine data exchange. It has a strict, unambiguous syntax using braces, brackets, and quotes, which makes it easy to parse consistently across different programming languages and environments. JSON does not support comments, references, or multi-document files.
Since YAML is a superset of JSON, any valid JSON document is also valid YAML. The reverse is not true: YAML-specific features like anchors, aliases, and block scalars have no direct JSON equivalents and must be transformed during conversion. The result is always valid JSON but may be more verbose than the original YAML.
How to Use This Tool
Follow these steps to convert YAML to JSON:
- 1
Paste your YAML content
Copy your YAML configuration file or data into the input panel. Single-document and multi-document YAML files (using --- separators) are both supported.
- 2
Click Convert
Press the Convert button. The tool parses the YAML, resolves all anchors and aliases, and serializes the result as JSON. Any YAML syntax errors are displayed with line numbers.
- 3
Choose output format
Select between pretty-printed JSON (with indentation and line breaks) for readability, or minified JSON (compact, no whitespace) for use in APIs, environment variables, or configuration systems that expect compact JSON.
- 4
Handle multi-document output
If your input is a multi-document YAML file, the output is a JSON array containing one element per YAML document. You can also choose to output only the first document if that is all you need.
- 5
Copy or download the JSON
Use the Copy button to place the JSON on your clipboard for immediate use, or download it as a .json file for storage or further processing.
Common Use Cases
YAML to JSON conversion serves a wide range of development and operations workflows:
- Converting Kubernetes YAML manifests to JSON for use with the Kubernetes API directly or with JSON-based tools like kubectl with --output=json
- Transforming Helm values.yaml files to JSON for passing as configuration to JSON-consuming deployment automation
- Converting GitHub Actions workflow YAML to JSON for programmatic analysis or transformation with jq
- Turning application configuration files from YAML to JSON for storage in systems like AWS Parameter Store or Consul that use JSON values
- Debugging complex YAML configurations by converting to JSON and exploring the resolved structure (especially useful for files heavy with anchors and aliases)
Tips and Best Practices
Get reliable conversions with these tips:
- Validate your YAML with a linter before converting. A well-formed YAML file is much easier to debug than conversion errors that point to the wrong line number in the resolved output.
- Remember that YAML comments are lost during conversion because JSON has no comment syntax. If you need to preserve documentation, move it to a separate README or use a JSON5-style convention in the output.
- YAML timestamps (e.g., 2025-01-15) are parsed as Date objects by many YAML parsers and then serialized as ISO 8601 strings in JSON. Verify that your downstream system handles the string format correctly if you are converting YAML with date values.
- YAML booleans include non-JSON values: 'yes', 'no', 'on', 'off' are all parsed as booleans in YAML 1.1 (though YAML 1.2 restricts this to 'true' and 'false'). Check which YAML version your source uses to avoid unexpected boolean coercion.
- For CI/CD pipelines that need YAML-to-JSON conversion at build time, consider using the Python yq tool or the Go version of yq on the command line rather than a browser tool, for automation and scripting.
Frequently Asked Questions
Do YAML anchors and aliases work correctly in the conversion?
Yes. Anchors and aliases are resolved during YAML parsing, before the JSON serialization step. The output JSON contains the fully expanded values, so aliases are replaced with copies of the data they reference. This means the JSON output may be larger than the YAML input if anchors are used extensively.
Can I convert a multi-document YAML file?
Yes. Multi-document YAML files (using --- separators) are parsed as a sequence of documents. The JSON output is a JSON array where each element corresponds to one YAML document. You can also configure the tool to output only the first document if you need a single JSON object.
What happens to YAML-specific types like timestamps and binary?
YAML timestamps are converted to ISO 8601 strings (e.g., 2025-01-15T00:00:00Z). Binary data encoded as base64 YAML scalars is preserved as a base64 string in JSON. Null values in YAML (expressed as ~, null, or an empty value) become JSON null.
Is the output valid JSON?
Yes. The tool produces standard JSON (RFC 8259) output. Optionally it can produce JSON5 output, which supports comments and trailing commas, but this is off by default since JSON5 is not universally supported.
Can I reverse the process and convert JSON back to YAML?
Yes. Our JSON to YAML converter performs the reverse transformation. Since JSON is a subset of YAML, this conversion is straightforward: all JSON documents are valid YAML, and the converter adds YAML-style formatting and optional features like anchors for repeated values.
Why does the output JSON have more characters than my YAML?
YAML is designed to be compact and human-readable, using indentation and implicit types to reduce verbosity. JSON requires explicit quoting of all strings, curly braces for objects, and square brackets for arrays. The JSON representation of the same data is therefore typically larger than the equivalent YAML.
Ready to use this tool?
Free, instant, no account required. Runs entirely in your browser.