JSON to YAML converter

free

Convert JSON to YAML with sortable keys, configurable indent, and flow level.

JSON
342 chars · 342 BValid
YAML
server:
  host: 0.0.0.0
  port: 3000
  tls:
    enabled: true
    certPath: /etc/ssl/cert.pem
database:
  host: db.internal
  port: 5432
  pool:
    min: 2
    max: 10
features:
  - auth
  - billing
  - analytics
debug: false
226 chars · 226 B

Convert JSON to YAML using the battle-tested js-yaml dumper. Configurable indent (2 / 4 / 8) to match your team's convention, line-width wrapping so long strings break cleanly, and alphabetical key sorting for diff-friendly output. Useful for converting between JSON and YAML config formats without manual hand-translation.

Common use cases

  • Migrating CI config from JSON to YAML. GitHub Actions, CircleCI, GitLab — all use YAML. If you have an existing JSON config (or are generating one from a script), convert to YAML for human-readable check-in.
  • Kubernetes manifests from JSON. kubectl accepts both, but the community standard is YAML. Convert ConfigMaps, Secrets, and Deployments from JSON snippets to YAML for cleaner review in PRs.
  • Docker Compose translation. When you have a programmatically-generated JSON description of services, convert to YAML for use with `docker compose`.
  • Translating API responses to readable config. JSON's noise (quotes, commas, braces) makes it hard to read at a glance. YAML's whitespace-led syntax is much easier for human review.

Frequently asked

Why does my YAML have `'` around some values?

js-yaml quotes strings when they could otherwise be interpreted as another type — `'yes'`, `'no'`, `'true'`, `'12'`, `'on'`. These are YAML 1.1 ambiguities; the quotes preserve string semantics.

Should I sort keys?

Helpful for config files that go through code review — sorted keys make diffs predictable and small. Avoid sorting for ordered configs (Kubernetes containers, Docker compose services) where source order is meaningful.

What's `flowLevel`?

Controls when YAML switches from block style (newlines, indentation) to flow style (`{a: 1, b: 2}`). `-1` keeps everything in block style — most readable. Positive numbers force compact inline syntax past that depth.

Does it preserve comments from JSON?

JSON doesn't have comments. If your source is JSON5 or JSONC with `//` comments, strip them first — the YAML output will be comment-free regardless.

Can I convert YAML to JSON?

Use the JSON formatter (paste YAML into JSON formatter and use its parsing). A dedicated bidirectional swap on this page is on the roadmap.

Why is my indent option specifically 2 / 4 / 8?

The YAML spec requires indentation to be consistent and explicit. js-yaml accepts arbitrary numbers but most communities standardise on 2 (Kubernetes, Ansible) or 4. 8 is occasionally used for highly nested configs to keep scope visible.