consolelog.tools

JSON to YAML

Convert JSON to YAML live — with optional lenient JSON input (comments, trailing commas, single quotes), key sorting and indentation.

About this ToolHow it works, benefits & use cases

Convert JSON into readable YAML, generated live as you type. Powered by the js-yaml dumper, it emits clean block-style YAML with your choice of 2- or 4-space indentation and never wraps long lines, so string values stay on one line. You can optionally sort object keys alphabetically for tidy, diff-friendly output. A lenient input mode means you do not need perfectly strict JSON: with repair enabled, single quotes, trailing commas and // or /* */ comments are accepted and normalised before conversion, and a banner confirms when lenient parsing is in effect. Invalid JSON that cannot be repaired produces a clear error message rather than a failure. The resulting YAML streams live and can be copied, downloaded as a .yaml file, or shared via URL, and the entire conversion happens in your browser with nothing uploaded.

How to Use

  1. 1Choose the YAML indentation, either 2 or 4 spaces.
  2. 2Toggle "Sort keys" for alphabetical key order, and enable "Repair (lenient)" if your JSON has comments, trailing commas or single quotes.
  3. 3Paste your JSON into the input panel — the YAML appears live — or click "Load example" (it matches your repair setting).
  4. 4Press "Convert to YAML" to validate the input.
  5. 5Copy the YAML, download it as output.yaml, or share it with the generated URL.

Key Benefits

  • Clean block-style YAML output via the js-yaml dumper
  • Selectable 2- or 4-space indentation with no line wrapping
  • Optional alphabetical key sorting for stable diffs
  • Lenient mode accepts comments, trailing commas and single quotes in the JSON
  • Clear error messages when input cannot be parsed or repaired
  • Live conversion with copy, .yaml download and shareable URLs
  • Processed entirely in the browser — your data is never uploaded

Common Use Cases

  • Turning a JSON config into a more human-readable YAML manifest
  • Producing YAML for CI pipelines or Kubernetes from JSON data
  • Converting hand-written JSON5-style snippets into valid YAML via repair mode
  • Normalising key order before committing generated YAML
  • Quickly translating an API JSON response into YAML for documentation

Options

Accept comments / trailing commas / single quotes

0 characters · live

Paste JSON above to see the YAML live.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools