How It Works
The converter parses your YAML input by analyzing indentation levels to reconstruct the document hierarchy. Each indented block becomes a nested object, lines starting with - become array elements, and scalar values are automatically typed as strings, numbers, booleans, or null. The reverse direction serializes JSON into clean, human-readable YAML with proper indentation.
Everything runs client-side in your browser. No data leaves your machine, so config files with database credentials or API keys stay private.
YAML vs JSON Comparison
| Feature | YAML | JSON |
|---|---|---|
| Readability | Designed for humans, indentation-based | Verbose with braces and quotes |
| Comments | Supported with # | Not supported in spec |
| Data types | Strings, numbers, booleans, null, dates, binary | Strings, numbers, booleans, null, arrays, objects |
| Multiline strings | Native support with | and > operators | Requires escape characters (\n) |
| File size | Smaller (no quotes or braces) | Larger due to syntax overhead |
| Parsing speed | Slower (indentation parsing) | Faster (well-defined grammar) |
| Common use | Config files, Docker Compose, Kubernetes, CI/CD | APIs, data exchange, package manifests |
| Anchors/aliases | Supported (& and *) | Not supported |
YAML Syntax Quick Reference
| Syntax | Meaning | Example |
|---|---|---|
key: value | Key-value pair | name: Alice |
nested: | Nested object (indent 2 spaces) | server:
port: 8080 |
- item | Array element | - redis
- postgres |
[a, b, c] | Inline array | tags: [dev, staging] |
| | Multiline string (preserves newlines) | description: |
Line 1
Line 2 |
> | Folded string (joins lines with spaces) | summary: >
Long text
on two lines |
# comment | Comment (ignored by parser) | # database config |
~ or null | Null value | optional_field: ~ |
FAQ
Can I convert JSON back to YAML with this tool?
Yes. Click the direction toggle button at the top to switch between YAML-to-JSON and JSON-to-YAML modes. The converter handles both directions and produces clean, properly indented output in either format.
Does the converter preserve comments from YAML?
No. JSON has no comment syntax, so comments are stripped during conversion. This is a limitation of the JSON specification itself, not this tool. If you need to preserve comments, keep your original YAML file alongside the generated JSON.
How does the tool handle YAML multiline strings?
The pipe operator (|) preserves line breaks and the greater-than operator (>) folds lines into a single string separated by spaces. Both are converted to standard JSON string values with appropriate escaping.
What YAML features are not supported?
This converter handles the most common YAML patterns: key-value pairs, nested objects, arrays, inline syntax, multiline strings, and all standard scalar types. Advanced features like anchors (&), aliases (*), and custom tags are not supported. For documents using these features, use a full-spec YAML parser like js-yaml.
Working with TypeScript? Convert JSON to TypeScript interfaces or generate Zod schemas from JSON.