JSON to YAML

JSON YAML Converter Processed locally in your browser

Convert JSON and YAML online with formatting and validation.

Input
YAML result
Duplicate keys are rejected; anchors and aliases are expanded by js-yaml; dates stay strings; eval() is never used.
Privacy:Files and text are read and converted only in your browser. Nothing is uploaded, received, or stored by this site.

Online Converter with Arrays, Indentation and Quote Options

What Is JSON to YAML Conversion?

JSON to YAML conversion transforms structured JSON data into YAML format. JSON uses curly braces, square brackets and key-value pairs to represent data and is widely used in APIs and application communication. YAML uses indentation to represent hierarchy and offers a concise, readable syntax commonly used in application configurations, container deployments and automated workflows.

NZTool JSON to YAML converts JSON objects, arrays and nested data into YAML text locally in your browser. You can adjust indentation, quoting rules, array styles, multiline string formatting and YAML document markers, then copy or download the result. The tool also supports reverse YAML to JSON conversion without installing software or uploading data.

How to Convert JSON to YAML Online

  1. Open NZTool JSON to YAML and select JSON → YAML mode.
  2. Paste your JSON data into the input area, or try a built-in example to see how conversion works.
  3. Adjust indentation, quote styles, array formatting and multiline text options as needed.
  4. Click Convert to generate YAML text.
  5. Review the output hierarchy, arrays, strings and special characters.
  6. Click Copy to retrieve the result or Download to save the generated YAML file.

If your JSON contains syntax errors such as missing quotation marks, unmatched brackets or trailing commas, correct the input before converting.

JSON to YAML Example

The following JSON represents a simple application configuration:

{
  "app": {
    "name": "demo",
    "port": 8080,
    "debug": false,
    "tags": ["web", "api"]
  }
}

It can be converted into YAML as follows:

app:
  name: demo
  port: 8080
  debug: false
  tags:
    - web
    - api

YAML replaces most JSON brackets with indentation and uses hyphens for list items, making configuration structures easier to read.

How Are JSON Objects and Nested Structures Converted?

Key-value pairs in JSON objects usually become YAML mappings, while nested objects use indentation to represent parent-child relationships. For example:

{
  "server": {
    "host": "localhost",
    "port": 3000,
    "ssl": {
      "enabled": true
    }
  }
}

Equivalent YAML:

server:
  host: localhost
  port: 3000
  ssl:
    enabled: true

This structure is useful for application settings, service parameters and hierarchical data intended for human review.

How Are JSON Arrays Converted to YAML?

JSON arrays can be converted into YAML lists. NZTool offers block, inline and compact array display options so you can choose a format that suits your needs.

Example JSON:

{
  "users": [
    {"name": "Tom", "age": 20},
    {"name": "Alice", "age": 22}
  ]
}

Block-style YAML:

users:
  - name: Tom
    age: 20
  - name: Alice
    age: 22

Simple arrays can also use inline formatting:

tags: [web, api, test]

Different array styles mainly affect readability and layout. They should not change the order or types of array elements.

How Does JSON to YAML Preserve Data Types?

JSON supports strings, numbers, booleans, null, arrays and objects. YAML can represent these common types as well, but certain strings have special meanings in YAML and therefore require appropriate quotation marks.

JSON ValueYAML ExampleType
123123Number
truetrueBoolean
nullnullNull
"true"'true'String
"00123"'00123'String
[][]Empty array
{}{}Empty object

For example, the JSON string "true" is different from the boolean true. To prevent data types from changing when YAML is parsed again, the converter should quote strings that might otherwise be interpreted ambiguously.

How to Configure YAML Indentation

NZTool provides 2-space and 4-space indentation options. Indentation represents YAML data hierarchy, and the setting primarily affects output formatting.

  • 2 spaces: Compact output suitable for common configuration files.
  • 4 spaces: More visible nesting for complex structures.

YAML indentation normally uses spaces rather than tabs. Choose an indentation style that matches your project's formatting conventions.

What Are the JSON to YAML Quote Options?

The tool provides automatic, single-quote and double-quote strategies.

  • Automatic quoting: Selects suitable representations based on string content, balancing simplicity with correct data types.
  • Single quotes: Useful for many ordinary strings; embedded single quotes must be escaped according to YAML rules.
  • Double quotes: Useful for strings requiring escape sequences, such as newlines or special control characters.

Strings such as "00123", "true", "null" and "1.0" should be quoted appropriately when their string types must be preserved, preventing them from being mistaken for numbers, booleans or null values.

How Are JSON Multiline Strings Converted to YAML?

JSON represents line breaks with escape sequences such as \n. YAML provides two common multiline styles: Literal (|) and Folded (>).

Example JSON:

{
  "message": "Hello\nWorld\n"
}

Using the Literal style:

message: |
  Hello
  World

Literal generally preserves line breaks, while Folded combines certain line breaks according to YAML rules. The two styles are not interchangeable merely by replacing their symbols. For text requiring exact preservation of line breaks and trailing whitespace, verify that parsing the generated YAML reproduces the original string.

Can JSON to YAML Add Document Markers?

Yes. The tool provides an option to add the YAML document marker --- at the beginning of the output.

---
name: demo
version: '1.0'

Document markers are common in YAML configurations and files containing multiple documents. For a single YAML document, whether to include --- usually depends on the target system's requirements.

How Does JSON to YAML Handle Special Characters?

JSON strings and property names may contain colons, hash signs, quotation marks, backslashes, line breaks and Unicode characters. When converting to YAML, appropriate quoting and escaping must be selected for the context.

Example JSON containing special characters:

{
  "url": "https://example.com/api",
  "message": "Hello: World #1",
  "code": "00123"
}

Possible YAML representation:

url: https://example.com/api
message: 'Hello: World #1'
code: '00123'

Correct quoting prevents strings from being mistaken for YAML comments, mapping separators or other data types.

JSON to YAML vs. YAML to JSON

FeatureJSON to YAMLYAML to JSON
Input formatJSONYAML
Output formatYAMLJSON
Main purposeGenerate readable configuration dataConvert configurations into application-friendly data
ObjectsObjects become YAML mappingsMappings become JSON objects
ArraysArrays become YAML listsLists become JSON arrays
FormattingIndentation, quotes, arrays and multiline textJSON formatting, indentation and type recognition

NZTool supports conversion in both directions. However, YAML includes features such as comments, anchors, aliases and multiple documents that do not have fully equivalent JSON syntax. Therefore, lossless round-trip conversion is not guaranteed for all YAML content.

Common Uses for JSON to YAML

  • Application configuration: Turn JSON settings into more readable YAML.
  • Containers and deployment: Prepare structured data for YAML-based environments such as Docker Compose and Kubernetes.
  • CI/CD workflows: Convert JSON data into editable YAML configuration content.
  • API debugging: Convert JSON API responses to YAML to inspect hierarchy.
  • Learning data formats: Compare how JSON and YAML represent objects, arrays and primitive types.

Format conversion changes only the data representation. It does not automatically generate platform-specific configuration fields or validate the output against Kubernetes, Docker Compose or other application-specific configuration requirements.

Frequently Asked Questions

Can JSON be converted directly to YAML?

Yes. Enter valid JSON, select JSON → YAML mode and click Convert to generate YAML text.

Do I need to install software?

No. Conversion runs in your browser without desktop software.

Can JSON arrays be converted to YAML?

Yes. JSON arrays normally become YAML lists, using block or inline styles according to the settings.

Are numbers and booleans preserved?

The converter should preserve common JSON types that YAML can accurately represent. Numeric and boolean-looking strings require correct quoting to avoid type changes.

Can I customize YAML indentation?

Yes. Choose 2-space or 4-space indentation.

Are single and double quotes supported?

Yes. Select automatic, single-quote or double-quote strategies. The generated output must still follow YAML syntax.

Are multiline strings supported?

Yes. Literal and Folded multiline styles are available, but line-break semantics must be considered.

Can I add the --- marker?

Yes. Use the document marker option to control whether --- appears at the beginning of the YAML.

Why does JSON to YAML conversion fail?

Common causes include missing JSON quotation marks, unmatched brackets, trailing commas or invalid JSON syntax. Extremely deep nesting or unusual numeric values may also exceed converter limits.

Can I download the YAML file?

Yes. Copy the YAML text or use Download to save it.

Is my JSON uploaded to a server?

No. NZTool processes the input and output locally in your browser.

Free Online JSON to YAML Converter

NZTool JSON to YAML converts JSON objects, arrays, nested structures and primitive data types into readable YAML. Configure 2- or 4-space indentation, quote strategies, array styles, multiline strings and document markers. Copy or download the output, or switch to YAML to JSON conversion. Everything runs locally in your browser without installation.
  • JSON to YAML online: Paste JSON and generate readable YAML configuration data.
  • Objects and arrays: Convert nested objects, arrays, strings, numbers and booleans.
  • Custom indentation: Choose 2 or 4 spaces for YAML formatting.
  • Quote strategies: Automatic, single and double quotes for different strings.
  • Array formatting: Block, inline and compact display styles.
  • Multiline text: Configure Literal and Folded string styles.
  • Document markers and export: Add ---, copy results and download YAML.
  • Local two-way conversion: Convert YAML to JSON without server uploads.
Use NZTool JSON to YAML to create readable, maintainable YAML from JSON data for application settings, API debugging, container deployment and automated workflows. After conversion, check string quotes, array structures, multiline text and special characters against the target system's requirements. The tool converts data formats but does not validate platform-specific configuration rules.
Comments 0
No comments yet. Be the first to comment!
avatar
Comment content cannot be empty
0/255