HomeToolsDeveloper Tools › JSON to YAML Converter

JSON to YAML Converter

Paste any JSON and get clean, indented YAML instantly. Validates your JSON first — syntax errors show the exact position. 100% in-browser, nothing leaves your device.

Converted in your browser using js-yaml. Your JSON is never uploaded or stored.
JSON Input 0 chars

About JSON to YAML Converter

JSON to YAML Converter turns any valid JSON object into clean, readable YAML in one pass. Paste a configuration fragment, an API response, a Helm values blob, or a hand-written object literal — the converter validates the JSON first and shows the exact position of any syntax error before attempting conversion. Output uses 2-space indentation, produced by js-yaml 4.1.0 (MIT license). Nothing is uploaded; parsing runs locally in your browser.

Why developers convert JSON to YAML

Infrastructure tooling made YAML the dominant format for configuration: Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Helm charts, and Ansible playbooks all use YAML. APIs and programmatic code generation typically output JSON. The conversion step is routine — generate a config object in code, test it as JSON, then convert to YAML before committing the manifest. This tool handles that conversion in seconds without requiring a script, a library install, or a command-line dependency.

How the conversion works

The browser's native JSON.parse() validates and parses the input. Parse errors include the exact character position where the parse failed, so you can find the stray comma or missing bracket immediately. The parsed JavaScript object is then serialized using jsyaml.dump() from js-yaml with 2-space indentation. Objects render as key-value pairs at the correct indent level. Arrays render as block sequences with dash markers. Nested structures preserve depth without limit. The output is never truncated, even for large API response payloads.

String quoting behavior

YAML's type inference system parses unquoted strings and tries to detect booleans, nulls, and numbers. A JSON string value of "true" would be interpreted as the YAML boolean true without quotes. A JSON string value of "null" would become the YAML null literal. js-yaml automatically adds quotes to any string value that YAML's parser would re-interpret as a scalar type — so "true", "false", "yes", "no", "on", "off", "null", and numeric-looking strings are all quoted in the output. Values that are genuine JSON booleans and numbers convert to YAML without quotes, preserving type semantics correctly.

Long strings and URLs

Many YAML serializers fold long strings or wrap URLs at 80 characters, breaking Kubernetes manifest fields that contain multi-line commands or full URLs as scalar values. This converter disables line wrapping entirely. A 300-character URL in a JSON value appears as a single-line YAML scalar, which is what Kubernetes, GitHub Actions, and Docker Compose parsers expect. The only output style produced is block style — indented lists and maps. Flow style (inline { } and [ ]) and multi-line folded/literal block scalars are not produced. Embedded newline characters in strings serialize as \n escape sequences on one line.

Common use cases

Frequently asked questions

Why does the converter quote some string values but not others?

YAML parses unquoted values and applies type inference. Without quotes, <code>true</code> becomes a boolean, <code>null</code> becomes null, and <code>1.5</code> becomes a float. js-yaml quotes any string that YAML's type inference would change — preserving the original JSON semantics. Genuine JSON booleans and numbers convert without quotes.

Can I convert YAML back to JSON?

This tool is one-directional. For YAML-to-JSON, use a dedicated YAML-to-JSON converter.

What is js-yaml and what license does it use?

js-yaml is a widely used YAML parser and serializer for JavaScript. It is MIT licensed, meaning you can use it in commercial projects without restriction. This tool uses version 4.1.0. In your own code: <code>npm install js-yaml</code>, then <code>const yaml = require('js-yaml'); yaml.dump(obj, { indent: 2 })</code>.

Does this handle nested objects and arrays correctly?

Yes. JSON's nested object structure maps directly to YAML's indented block structure, and JSON arrays map to YAML block sequences (dash-prefixed lists). Nesting depth is not limited. Arrays of objects, objects containing arrays, and mixed nesting all convert correctly.

Why does YAML need 2-space indentation — can I change it?

2-space indentation is the convention in Kubernetes, GitHub Actions, and most infrastructure YAML files. The tool is fixed to 2 spaces because that is what the tooling ecosystem expects. If you specifically need 4-space indentation, you can post-process the output with a global replace of two leading spaces per indent level.

Keep going

More developer tools

LiveDeveloper

JSON Formatter & Validator

Format and validate JSON before converting — pretty-print minified input to confirm the structure is correct before running the YAML conversion.

Open tool
LiveDeveloper

XML Formatter

Format and validate XML — useful when working with infrastructure tooling that outputs XML alongside JSON and YAML configuration formats.

Open tool
LiveDeveloper

Base64 Encoder / Decoder

Encode YAML values that contain binary or special characters as Base64 — a common pattern in Kubernetes Secret manifests.

Open tool