Dev · Live
JSON to YAML Converter,
and back, with error detection.
Paste any valid JSON or YAML string and get an instantly formatted conversion. Invalid input shows a precise error with line and column number. Fully client-side — nothing is sent to a server.
Input lines
23
Input chars
433
Output lines
21
Output chars
312
Format reference
Key differences between JSON and YAML
| Concept | JSON | YAML |
|---|---|---|
| Object | { "key": "val" } | key: val |
| Array | ["a", "b", "c"] | - a - b - c |
| String | "hello world" | hello world |
| Number | 42 | 42 |
| Boolean | "true" / "false" | true / false |
| Null | "null" | null |
| Comments | not supported | # this is a comment |
Format guide
JSON and YAML: when to use which, and why they coexist.
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format derived from JavaScript object syntax. It was introduced by Douglas Crockford in the early 2000s and has become the de facto standard for data exchange on the web, supported natively by virtually every programming language and platform.
JSON supports six data types: strings (double-quoted), numbers, booleans (true/false), null, arrays (ordered lists), and objects (key-value maps). Keys must be strings. Its strict syntax — every string must be quoted, no trailing commas, no comments — makes it easy to parse programmatically and difficult to misinterpret.
What is YAML?
YAML (YAML Ain't Markup Language — a recursive acronym) is a human-readable data serialisation standard. It was designed explicitly to be more readable than JSON while remaining a strict superset of JSON: any valid JSON document is also valid YAML, but YAML adds many features that JSON lacks.
YAML uses indentation instead of brackets to represent structure, and most strings do not need to be quoted. It supports comments (with #), multi-line strings (block scalars), anchors and aliases for referencing repeated data, and multiple documents in a single file separated by ---.
Key differences
- Comments: YAML supports comments; JSON does not. This makes YAML significantly more suitable for configuration files that need inline documentation.
- Quoting: JSON requires double quotes around all keys and most values. YAML infers types automatically — plain text is treated as a string,
true/falseas booleans, and numbers as numbers — without requiring quotes. - Indentation: YAML uses whitespace indentation to denote nesting (like Python). JSON uses curly braces and square brackets, making it less sensitive to formatting but harder to read in deeply nested structures.
- Anchors and aliases: YAML allows you to define a value once with an anchor (
&anchorName) and reference it elsewhere with an alias (*anchorName), avoiding repetition. JSON has no equivalent. - Multi-document: YAML files can contain multiple documents separated by
---. JSON files contain exactly one top-level value.
When to use JSON
- API responses: JSON is the universal language of REST and GraphQL APIs. Its strict syntax makes it easy to validate and parse without ambiguity.
- Data storage and transmission: JSON is compact and easy to parse, making it suitable for databases (MongoDB, Firestore), message queues, and inter-service communication.
package.jsonand similar: Node.js ecosystem metadata files, browser extension manifests, and VS Code settings use JSON for its straightforward structure.
When to use YAML
- Configuration files: Docker Compose, Kubernetes manifests, GitHub Actions workflows, Ansible playbooks, and CI/CD pipelines (CircleCI, Travis CI) all use YAML because of its readability and support for comments.
- Infrastructure as code: AWS CloudFormation, Terraform variable files, Helm charts, and Serverless Framework configurations are written in YAML.
- Human-edited files: Any file a developer writes and reads regularly benefits from YAML's minimal punctuation and support for inline documentation.
- OpenAPI / Swagger: API specification files are commonly written in YAML for readability, though the spec also permits JSON.
Common YAML pitfalls
YAML's implicit typing can cause surprising behaviour. The YAML specification automatically converts unquoted values that match certain patterns: yes, no, on,off, true, false are all interpreted as booleans in YAML 1.1 (though YAML 1.2 restricts this). A Norwegian developer famously filed a bug: a country code list had Norway abbreviated as NO, which YAML silently converted to false.
Indentation errors are the most common source of invalid YAML. Tabs are not allowed as indentation in YAML — only spaces. Mixing tabs and spaces, or inconsistent indentation depth, will cause a parse error. This tool will report the exact line and column of any such error.
How this converter works
This tool uses js-yaml v4, the most widely used JavaScript YAML library (over 90 million npm weekly downloads). For JSON → YAML conversion, it parses with the native browserJSON.parse and serialises with yaml.dump. For YAML → JSON, it parses with yaml.load and serialises with JSON.stringify.
Everything runs in your browser. No data is transmitted to any server. The conversion and error detection happen locally, instantly, as you type.
Disclaimer
This converter handles standard JSON and YAML documents. YAML features that have no JSON equivalent — comments, anchors, aliases, multi-document files, custom tags — are either dropped or may cause an error during YAML → JSON conversion. For production pipelines, always validate the output against your target schema.