YAML ↔ JSON Converter
Convert YAML to JSON and back, right in your browser.
Runs in your browser — files never leave your device
How it works
This converter is built on js-yaml, the same YAML parser used across the Node.js ecosystem, and runs entirely in your browser. YAML → JSON parses one YAML document and pretty-prints the result as JSON with two-space indentation. JSON → YAML goes the other way, emitting block-style YAML: two-space indents, dash-prefixed list items, strings quoted only when necessary, and long lines folded at 80 characters.
A small example: a YAML document with name: api, replicas: 2 and a ports list of 8080 and 8443 converts to {"name":"api","replicas":2,"ports":[8080,8443]} — and feeding that JSON back produces the same YAML. Data always survives the round trip; presentation does not.
Three things are lost by design. Comments disappear, because JSON has no comment syntax. Anchors and aliases (&defaults / *defaults) are resolved during parsing, so every alias becomes a full copy of the referenced value in the JSON, and converting back never recreates the anchor. And multi-document streams separated by --- are rejected with expected a single document in the stream — split them and convert one document at a time.
Watch the type resolution, which follows the YAML 1.2 core schema. yes, no, on and off stay strings — only true and false are booleans — and unquoted dates like 2021-06-01 also stay strings. Number-like scalars are converted, though: zip: 01234 becomes the integer 1234 and version: 1.10 becomes 1.1, so quote any value whose leading or trailing zeros matter.
Typical uses: converting Kubernetes manifests, GitHub Actions workflows or docker-compose files to JSON so you can query them with jq or validate them against a JSON Schema; turning JSON API examples into cleaner YAML for docs and config files; migrating configuration formats; and debugging confusing YAML by seeing exactly how the parser understood it.
Frequently asked questions
- Which YAML features are supported?
- A single YAML document parsed by js-yaml with its default (YAML 1.2 core) schema: nested mappings and sequences, quoted, plain, folded and literal scalars, and anchors/aliases, which are resolved during parsing. Multi-document streams separated by --- are rejected with the error "expected a single document in the stream" — convert one document at a time.
- What happens to comments and anchors?
- Comments are dropped because JSON has no comment syntax. Anchors and aliases are expanded while parsing, so each alias becomes a full copy of the referenced value in the JSON output, and converting that JSON back to YAML does not recreate them. Data survives round trips; presentation does not.
- Why did 01234 turn into 1234?
- Unquoted scalars are type-resolved, so number-like values become numbers: zip: 01234 parses as the integer 1234 and version: 1.10 as the float 1.1, silently losing leading and trailing zeros. Quote such values ("01234") to keep them as strings.
- Is no parsed as false?
- Not here. Under the YAML 1.2 core schema only true and false are booleans, so yes, no, on and off stay strings — you can see it directly in the JSON output. Older YAML 1.1 parsers do read them as booleans (the classic Norway problem, where the country code no became false), so quote these words in files that other toolchains will read.
- What style of YAML does JSON → YAML produce?
- Block style throughout: two-space indentation, lists as "- " items, keys and strings quoted only when required, and lines longer than 80 characters folded into >- block scalars. The output is semantically identical to the input JSON even where the layout looks different.
- Is my config uploaded?
- No — js-yaml runs inside the page and nothing is sent over the network. Worth knowing, since real configs often contain connection strings and secrets.
Related tools
- Word & Character CounterCount words, characters, sentences, paragraphs and lines instantly. Runs entirely in your browser — your text never leaves your device.
- Case ConverterConvert text between UPPERCASE, lowercase, Title Case, camelCase, snake_case, kebab-case and more — instantly in your browser.
- Slug GeneratorTurn any title into a clean, URL-friendly slug. Removes accents and punctuation; runs in your browser.
- Text ReverserReverse any string character by character. Handles Unicode correctly; runs locally.
- Remove Duplicate LinesStrip duplicate lines from a list, keeping the first occurrence. Optional case-insensitive and trim modes.
- Sort LinesSort lines alphabetically, ascending or descending, with optional case-insensitive comparison.