My Tool Studio
Developer Tools·2 min read

JSON to YAML: Write Readable Config Files

Many config files are written in YAML, but the data you start from is often JSON, such as an API response or a kubectl -o json dump. The JSON to YAML Converter rewrites it as block-style YAML with 2-space indentation by default. It converts as you type and runs in your browser, so configs with secrets stay on your device.

.json.yamlJSON → YAML

What the converter produces

The layout most tools expect.

Objects become indented keys and arrays become dash lists. Numbers, booleans and null keep their types, and long strings stay on one line unless you tick Wrap long strings at 80 characters. Keys stay in the order they appear in the JSON, except that keys that look like whole numbers move to the front, which comes from JavaScript itself. Tick Sort keys A to Z if you want a stable order.

There is no button to press. Paste JSON in the left pane and the YAML appears on the right. If the JSON has a syntax error, the bad line is highlighted, Go to line jumps to it, and the YAML waits until the input parses.

Indent can be 2 or 4 spaces, and list items can sit under their key or at the same level. The Style menu keeps everything in block form, or writes deeper levels in compact inline form such as [a, b].

Why some strings are quoted

Protecting your types.

YAML reads unquoted values like false, 10 or null as a boolean, a number or null. If your JSON holds those as strings, the converter quotes them so they stay strings. Strings that start with characters that mean something in YAML, such as * or &, are quoted for the same reason. This avoids a classic config bug where a version string turns into a number.

The Quotes menu picks single or double quotes for those cases, or Quote every string wraps all string values, which some style guides prefer.

Kubernetes and Docker Compose

Where it is used most.

The output is standard YAML that kubectl apply -f accepts. Press Try sample to load a Kubernetes Deployment written as JSON, then try the presets. Kubernetes (kubectl style) puts list items at the same indent as their key, while Docker Compose and GitHub Actions set the layout those files usually use.

A JSON array normally becomes one YAML list. If it holds several manifests, tick Top-level array as separate documents (---) and each object becomes its own document, ready for one kubectl apply.

JSON has no comments, so there is nothing to carry over. Add # comments to the YAML by hand after you copy it. Pick .yaml or .yml before you press Download; either extension works.

Going from YAML back to JSON

The reverse direction.

The YAML to JSON Converter handles the other way. It also reads files with several documents separated by --- and expands anchors and aliases, so you see the final values. This page converts rather than edits, so do heavier editing in your code editor, which can check YAML as you type.

Try it now

Open JSON to YAML Converter

The tool is one click away. No sign up, no upload, no payment.

Open JSON to YAML Converter