HomeToolsConversionJSON to YAML Converter

JSON to YAML Converter

Convert standard JSON files into clean, readable, space-indented YAML.

Conversion
Input Format
Converted Output

Convert simple JSON objects into indented YAML

This JSON to YAML converter provides a quick, automatic rendering for straightforward object-shaped data. It parses strict JSON, walks each object property, and writes a two-space-indented YAML-style mapping. Nested objects become nested mappings, arrays become dash-prefixed sequences, and primitive values are written after key:.

The implementation is deliberately small. It does not use a complete YAML serialization library, quote ambiguous strings, preserve type metadata, or validate its output with a YAML parser. It works best for controlled JSON containing ordinary property names, nested objects, primitive arrays, and uncomplicated scalar text. Understanding those boundaries is essential before placing the result in Kubernetes, CI, Docker Compose, or another configuration system.

What appears in the two panels

The Input Format panel starts with a project configuration sample. Editing it triggers conversion immediately; no Convert button is required. Converted Output is read-only and shows either generated text or Error: followed by the JSON parser message.

After a successful conversion, Copy puts the output on the clipboard and briefly changes to Copied. The action is disabled when output is empty or parsing has failed. There is no upload, download, clear, indentation, flow-style, document-marker, or quoting option.

To use the page:

  1. Replace the sample with one valid JSON object.
  2. Review the generated mapping, especially strings and arrays.
  3. Fix any JSON syntax error shown in the output panel.
  4. Copy the result after it appears.
  5. Validate and adjust the YAML with the parser used by the destination system.

The serializer’s mapping rules

For each object property, the converter checks its value. A nested non-null object starts a new mapping line and is processed at two additional spaces of indentation. An array starts a sequence whose items use - . All other values are appended directly after a space.

Input:

{
  "service": "checkout",
  "enabled": true,
  "replicas": 3,
  "metadata": {
    "region": "eu-west-1",
    "owner": null
  },
  "ports": [8080, 8081]
}

Output:

service: checkout
enabled: true
replicas: 3
metadata:
  region: eu-west-1
  owner: null
ports:
  - 8080
  - 8081

This is the ideal input shape for the current converter. Object nesting is visible, primitive arrays are readable, and the plain scalar strings contain no syntax that needs YAML-specific quoting.

Object key order follows the parsed JavaScript object’s enumeration order. Keys are not alphabetized. JSON formatting and whitespace do not affect output because the source is parsed before serialization.

Arrays require extra attention

Primitive arrays are emitted as expected: every value is interpolated after a dash. The array serializer does not recursively serialize each array item, however. Objects and nested arrays inside an array are converted through JavaScript string coercion.

For example:

{
  "users": [
    { "name": "Ana", "active": true },
    { "name": "Bo", "active": false }
  ]
}

does not become a YAML sequence of mappings. It produces:

users:
  - [object Object]
  - [object Object]

Similarly, a nested array item can become comma-joined text. Do not use this page unchanged for arrays of objects. Restructure such data, convert those sections with a full YAML library, or manually repair and validate the result.

An empty array still emits its key followed by a newline but no [] marker or child item. Depending on following content, that can be interpreted as null rather than an empty sequence. Empty nested objects likewise have no explicit {} representation. These are information-losing cases.

Plain scalars are not automatically quoted

JSON strings are written without YAML quotes or escaping. A simple value such as "dark" becomes dark, but values that resemble YAML booleans, numbers, nulls, dates, comments, or collection syntax may change type when another parser reads them.

Consider:

{
  "answer": "yes",
  "code": "0012",
  "note": "ready # pending review",
  "message": "line one\nline two",
  "label": "a: b"
}

The serializer does not add protective quotes, escape #, or choose a block scalar for the newline. The generated text may be misinterpreted or malformed. Exact behavior also varies between YAML versions and parsers; for example, YAML 1.1 and 1.2 differ for words such as yes and on.

Property names are also emitted directly. Keys containing a colon, comment marker, leading dash, braces, brackets, or unusual whitespace may need quoting. The tool neither quotes nor rejects them.

Where this quick conversion is useful

Translate a small settings object

Simple application preferences with alphanumeric keys, nested maps, booleans, numbers, and plain words convert cleanly. Review the result before replacing an existing configuration file.

Draft readable documentation

Convert a compact JSON example into a YAML-shaped snippet for discussion. Because the mapping is easy to see, it can save typing when the sample avoids ambiguous values. Clearly label it as illustrative until it has been parsed successfully.

Learn structural differences

The output demonstrates mapping indentation and dash sequences without YAML’s advanced syntax. Comparing it with the JSON source helps explain how braces, brackets, commas, and quoted keys disappear in block-style YAML.

Bootstrap a configuration migration

Use the result as a starting draft, then add quotes, explicit empty collections, multiline scalars, and any platform-specific document structure. A migration should finish with the target application’s parser and tests, not with clipboard output alone.

Troubleshooting the input and output

The output begins with Error

The source is parsed as strict JSON. Remove comments and trailing commas, use double quotes, and balance braces and brackets. YAML syntax cannot be used in the input panel.

An array says [object Object]

The current array loop supports primitive items only. Object items are coerced to text. Use a full recursive serializer for list-of-object data.

A string changed type after loading the YAML

The converter emits unquoted scalars. Manually quote values such as "yes", "null", "0012", timestamps, or other strings that a YAML parser may resolve to a non-string type.

Text after # disappeared

In YAML plain scalars, a spaced # can begin a comment. Quote the complete value and escape it according to YAML rules.

Empty arrays or objects no longer look empty

The serializer does not emit [] or {}. Add those explicit collection markers manually where emptiness must be preserved.

The root array has numbered keys

The top-level routine iterates properties rather than recognizing the root itself as a sequence. Root array indexes can therefore be rendered as mapping keys such as 0: and 1:. Wrap the array under a named property for primitive items, or use another converter for a true root sequence.

Unsupported YAML capabilities

The output has no document start marker, tags, anchors, aliases, merge keys, comments, directives, flow collections, block scalar selection, custom type handling, or multi-document streams. JSON has no native representation for many of these features anyway, and the converter does not invent one.

It also does not escape string values, quote keys, detect circular references, sort keys, choose line endings, or report YAML-level errors. Large input is parsed and recursively rendered in browser memory. Deep objects may reach recursion limits.

For production configuration, use a maintained serializer that targets the expected YAML version, then parse the generated file with the exact runtime or deployment tool that will consume it. Round-trip testing is the safest way to verify that strings and empty collections survived.

JSON to YAML FAQ

How many spaces are used for nesting?

Two spaces are added at each nested object level. There is no indentation setting.

Are arrays supported?

Arrays of primitive values receive dash items. Arrays containing objects or nested arrays are not serialized structurally and require another approach.

Are strings quoted automatically?

No. Values and keys are emitted directly, so ambiguous or syntax-sensitive text must be quoted manually.

Does the converter preserve comments?

JSON input cannot contain standard comments, and the serializer does not create YAML comments.

Can it convert a root JSON array?

Not into a normal root YAML sequence. The algorithm is designed around an object at the root.

What happens to null?

It is written as the plain scalar null, which typical YAML parsers resolve as a null value.

Can I download a .yaml file?

No. The current interface provides Copy only.

Is the generated text guaranteed to parse as YAML?

No. Unquoted keys or values, multiline strings, and object array items can make it invalid or change meaning. Always validate the copied result.

Learn More

Read our comprehensive guide to master this utility.

Read Guide →