Skip to main content
UFOZoo

YAML to JSON: Convert Docker/K8s Config Files Online

YAML to JSON converter online: convert Docker and Kubernetes config files into valid JSON for tools and APIs, with nested mapping support.

Updated 2026-08-26

Related Tools

Features

  • Bidirectional conversion: YAML to JSON and JSON to YAML with one click
  • Real-time validation with precise error location: highlights the exact line number in red when syntax is invalid
  • Supports complex nested structures including objects, arrays, and multi-level hierarchies
  • Handles YAML anchors (&), aliases (*), merge keys (<<: *), and custom tags
  • Preserves data types: numbers stay numbers, booleans stay booleans, null stays null
  • Line numbers displayed by default for easy reference when debugging or comparing diffs
  • Drag-and-drop files or click to browse: supports .yaml and .yml files
  • Download converted output as .json or .yml file with one click
  • Copy to clipboard with one click for easy sharing
  • Works offline after first load
  • Common use cases: Docker Compose, Kubernetes manifests, GitHub Actions, and CI/CD pipelines

How to Use

  1. 1Paste your YAML or JSON data into the left panel. It auto-detects the format and converts instantly as you type.
  2. 2When validation fails, the error line number turns red in the input panel; hover over it to see the error message.
  3. 3Drag a .yaml or .yml file onto the input area to load it instantly. No server upload required.
  4. 4Click Copy or Download on the right toolbar to save your converted result.
  5. 5The tool auto-detects input format: paste YAML to get JSON output, paste JSON to get YAML output.
  6. 6Use the Upload button to open a .yaml, .yml, or .json file from your device's file picker.
  7. 7Check the output after conversion; YAML anchors (&) and aliases (*) are resolved in the JSON output.
  8. 8Download the conversion result as either .json or .yml file depending on your needs.
  9. 9Use the Copy button to grab the output and paste it into your IDE, CI/CD config, or Kubernetes manifest.

Frequently Asked Questions

What is YAML?

YAML (YAML Ain't Markup Language) is a human-readable data serialization format commonly used for configuration files, Kubernetes manifests, CI/CD pipelines, and API specifications. It's designed to be easy to write and read for humans while being easily parsed by machines. Unlike JSON, YAML supports comments, multi-line strings, anchors, aliases, and doesn't require quotes around most strings.

What is the difference between YAML and JSON?

YAML is more human-readable with minimal syntax (no brackets or commas), supports comments (#), anchors (&), aliases (*), and multi-line strings. JSON is more strict, widely supported in APIs, generally faster to parse, and is natively supported by all programming languages. They can represent the same data structures; this tool converts between them cleanly.

How do I convert JSON to YAML?

Simply paste your JSON content in the left panel; the tool automatically detects the format and converts it to YAML. It handles nested objects, arrays, special characters, and complex structures. The conversion preserves data types (strings, numbers, booleans, null) and produces clean, properly indented YAML output ready for use in Docker Compose, Kubernetes, or any config file.

Does this tool support YAML anchors and aliases?

Yes! The tool uses js-yaml library which fully supports YAML 1.2 features including anchors (&), aliases (*), merge keys (<<: *), and custom tags. These are resolved before converting to JSON, so you'll see the expanded values in the output. For example, &defaults creates an anchor named 'defaults', and *defaults references it elsewhere.

How do I convert YAML to JSON with yq or the command line?

yq (the YAML counterpart of jq) does it in one line: yq e -o=json file.yml. Alternatives without installing yq: ruby -ryaml -rjson -e 'puts JSON.generate(YAML.load_file("file.yml"))', or Python (see below). For occasional conversions this web tool is the zero-install option with the same result.

How do I convert YAML to JSON in Python?

Install PyYAML, then: yaml.safe_load(open('file.yml')) to parse and json.dumps(...) to serialize. Two behaviors to expect: anchors and aliases expand into their full values, and comments disappear, exactly what this tool does.

What YAML version is supported?

The tool supports YAML 1.2 (the latest standard). Most modern YAML files use YAML 1.2, including Kubernetes manifests, GitHub Actions workflows (.github/workflows/*.yml), Docker Compose files (docker-compose.yml), GitLab CI (.gitlab-ci.yml), Ansible playbooks, and OpenAPI/Swagger specs. If you have very old YAML 1.0 files, they should still work for basic structures.

Can I convert large YAML files?

Yes, there's no strict file size limit, but very large files (10MB+) may slow down your browser. For typical use cases (Docker Compose files, Kubernetes deployments, CI/CD configs), it handles them instantly. If you need to convert huge files (100MB+), consider using command-line tools like yq (jq for YAML) or Python's PyYAML library.

Why does my YAML show as invalid?

Common issues: incorrect indentation (YAML uses spaces, not tabs, and indentation matters), missing colons after keys, unquoted special characters (:, {}, [], &, *, #), trailing commas (not allowed in YAML), inconsistent indentation levels, mixing spaces and tabs. The validator shows the exact line and column where it fails; look for red highlighting in the line numbers. Tip: Use 2-space indentation consistently.

Does it work on mobile?

Yes, but the experience is better on desktop. On mobile, the input/output panels stack vertically, and you can still copy/save results. For best results, use landscape mode on tablets when editing large YAML files.

Why do my YAML comments disappear in the JSON output?

Because JSON has no comment syntax; anything after # is dropped during conversion, so check the output before overwriting your original file. Anchors and aliases, by contrast, are expanded into their full values (a &defaults anchor becomes repeated inline values) and merge keys are resolved, which is why the JSON output can be longer than the YAML input.

Why does my yaml to json converter online show an error for a YAML file that works in my editor?

Editors highlight YAML without validating it strictly, and some libraries are lenient about YAML 1.1 quirks (yes/no/on/off become booleans, tabs accepted) while this tool parses YAML 1.2 strictly: tabs are never valid indentation, duplicate keys are rejected, unquoted special values (e.g., 1:30) are errors, and flow collections must be balanced. The error message gives the exact line and column; fix that spot, or quote the value ('yes', '1:30') to force a string.

Why does my yaml to json keep '123' as a string instead of a number?

Because quoting decides the type: in YAML, 123 is a number, while '123' or "123" is a string, and the converter preserves that distinction; JSON has both types, so nothing is coerced. The same applies to true vs 'true' and dates. If your JSON output must contain numbers, remove the quotes in the YAML; if an API expects strings, keep them. YAML 1.1's extra coercions (yes → true) do not apply here since the tool follows YAML 1.2.