YAML ↔ JSON Converter & Formatter
Convert between YAML and JSON formats, or format and validate your YAML. Auto-detects input format. Free and runs entirely in your browser.
How to Use
- Paste your YAML or JSON into the input area — the tool auto-detects the format
- Click 'To JSON' to convert to JSON, or 'To YAML' to convert to YAML
- Use 'Format YAML' to prettify a YAML document without converting
- Use 'Minify' to produce compact single-line JSON output
- Adjust the indent selector to control output indentation
- Click Copy to copy the result, or Clear to reset
Frequently Asked Questions
-
What is YAML?
YAML (YAML Ain't Markup Language) is a human-readable data serialization format commonly used for configuration files, CI/CD pipelines, and Kubernetes manifests. It uses indentation to represent structure instead of braces.
-
When should I use YAML instead of JSON?
Use YAML for configuration files and files humans will read or edit directly, as it supports comments and is less verbose. Use JSON for API responses and data interchange, as it is more universally supported and strictly defined.
-
Can YAML represent everything JSON can?
Yes. JSON is a subset of YAML — any valid JSON is also valid YAML. YAML additionally supports comments, multi-line strings, anchors, and aliases.
-
Is my data sent to a server?
No. All conversion happens entirely in your browser using the js-yaml library. Your data never leaves your device.
-
What happens if my input is invalid?
An error message will appear below the buttons describing exactly where the parsing failed, so you can quickly locate and fix the issue.
YAML and JSON: Two Formats, One Data Model
YAML and JSON represent the same underlying data model — nested structures of mappings (objects), sequences (arrays), and scalar values (strings, numbers, booleans, null). The difference is entirely in syntax and human-readability.
Because JSON is a strict subset of YAML, any valid JSON document is also valid YAML. This means converting from JSON to YAML is always lossless. Converting from YAML to JSON is also lossless for most documents, with one important exception: comments. YAML supports comments (lines starting with #); JSON does not. Comments are discarded when converting to JSON.
When to Use Each Format
Use YAML when:
- Humans will read, write, or edit the file directly
- The configuration is complex enough that comments would help (documenting why a value is set, marking deprecated keys, etc.)
- You're working in an ecosystem where YAML is the convention (Kubernetes, Ansible, GitHub Actions)
- Multi-line strings are needed — YAML's block scalars (
|and>) are far more readable than JSON's escaped newlines
Use JSON when:
- The data will be consumed by an API or transmitted over HTTP
- You need strict, predictable parsing across many languages and platforms
- Schema validation is important (JSON Schema is more mature than YAML Schema tools)
- The consumer is JavaScript/TypeScript code (JSON parses natively)
YAML Features That Don't Exist in JSON
Comments: # This is a comment — invaluable for configuration files.
Multiline strings:
description: |
This is a long string
that spans multiple lines
and preserves newlines.
Anchors and aliases: Reuse values to avoid repetition.
defaults: &defaults
timeout: 30
retries: 3
production:
<<: *defaults
host: prod.example.com
Implicit types: true, false, null, integers, and floats are automatically typed without quotes.
Common Conversion Pitfalls
YAML booleans: In YAML 1.1 (used by many parsers), yes, no, on, off are booleans. If you have a key with value yes that should be the string "yes", quote it: "yes". After converting to JSON, it will correctly appear as "yes" (a string) or true depending on how the YAML was written.
Large integers: YAML and JSON handle large integers differently across parsers. Numbers beyond the safe integer range (2^53 - 1) may lose precision in JavaScript-based converters.