YAML to JSON

JSON YAML Converter Processed locally in your browser

Convert JSON and YAML online with formatting and validation.

Input
JSON to YAML settings
YAML to JSON settings
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 YAML and JSON Converter for Arrays, Types and Multiple Documents

What Is YAML to JSON Conversion?

YAML to JSON conversion is the process of parsing YAML data and transforming it into JSON. YAML is a human-readable structured data format that commonly uses indentation to represent hierarchy. It is widely used in configuration files, automated deployment and development tools. JSON represents data through objects, arrays and primitive types and is commonly used in web APIs, frontend-backend communication and application data exchange.

NZTool YAML to JSON lets you paste YAML text into your browser and convert objects, arrays, nested structures, numbers, booleans, null values and multiline strings into JSON. It provides JSON formatting, indentation, data type recognition and multiple-document handling options, as well as a JSON to YAML mode. Results can be copied or downloaded directly. All processing happens locally in your browser without server uploads.

How to Convert YAML to JSON Online

  1. Open NZTool YAML to JSON and select YAML → JSON mode.
  2. Paste the YAML text you want to convert into the input area.
  3. Check indentation, colons, list markers and quotation marks.
  4. Expand the conversion settings if needed to configure JSON formatting, indentation, number and boolean recognition, and multiple-document handling.
  5. Click Convert to parse the YAML and generate JSON.
  6. Review the output to verify object nesting, array structure and field types.
  7. Click Copy or Download to save the converted JSON.

If YAML parsing fails, review the error message and check indentation, property names, quotation marks and list structure. YAML uses spaces to represent hierarchy, so incorrect indentation can cause parsing errors or unexpected data structures.

YAML to JSON Example

The following YAML represents an application configuration:

app:
  name: demo
  port: 8080
  debug: false
  database:
    host: localhost
    enabled: true
  tags:
    - web
    - api

Converted JSON:

{
  "app": {
    "name": "demo",
    "port": 8080,
    "debug": false,
    "database": {
      "host": "localhost",
      "enabled": true
    },
    "tags": [
      "web",
      "api"
    ]
  }
}

After conversion, YAML indentation becomes nested JSON objects, YAML lists become JSON arrays, and numbers and booleans are output according to the selected type recognition rules.

How Are YAML Objects and Nested Structures Converted to JSON?

YAML uses indentation to express object hierarchy, while JSON uses curly braces to define objects.

For example:

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

Can become:

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

This conversion is useful for turning hierarchical configuration data into JSON objects that applications can parse directly.

How Are YAML Lists Converted to JSON Arrays?

YAML commonly uses hyphens to indicate list items. In JSON, the corresponding structure is an array enclosed in square brackets.

For example:

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

Converted JSON:

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

YAML also supports inline arrays, such as tags: [web, api, test]. Both block-style lists and inline lists can generally be converted into JSON arrays.

How Does YAML to JSON Handle Numbers, Booleans and Null?

YAML supports basic types such as strings, numbers, booleans and null values. NZTool provides options for number recognition and boolean/null recognition to control how certain scalar values are handled.

YAML ValueTypical JSON ResultType
2525Number
19.9919.99Number
truetrueBoolean
falsefalseBoolean
nullnullNull
"00123""00123"String

Quoted values generally represent strings. For example, "00123" should retain its leading zeros rather than be interpreted as an ordinary integer. Numbers beyond JavaScript's safe integer range also require attention to precision. Actual type handling depends on the YAML parser rules and selected settings.

How Are YAML Multiline Strings Converted to JSON?

YAML supports multiline strings using the vertical bar | and greater-than sign >.

For example:

message: |-
  Hello
  World

Can become:

{
  "message": "Hello\nWorld"
}

The vertical bar generally preserves line breaks, while the greater-than sign folds certain line breaks. In JSON, newline characters are represented using escape sequences. YAML's trailing newline indicators, including |, |- and |+, can produce different string values and should be handled carefully.

Does YAML to JSON Support Multiple YAML Documents?

Yes, multiple-document handling is available. YAML can separate documents using ---, while a standard JSON text contains only one top-level value.

For example:

---
name: Tom
---
name: Alice

With the convert-to-array option, the result can be:

[
  {
    "name": "Tom"
  },
  {
    "name": "Alice"
  }
]

If the error-on-multiple-documents option is selected, the tool requires the input to contain only one YAML document. When multiple documents are converted to a JSON array, the original document boundaries are no longer preserved as separate JSON metadata and may not be restored automatically during reverse conversion.

How to Configure JSON Formatting and Indentation

NZTool provides a JSON formatting switch and indentation options, allowing you to generate readable or compact JSON according to your needs.

  • Formatted JSON: Uses line breaks and indentation to display objects and arrays clearly.
  • 2-space indentation: A compact, readable choice for development and API debugging.
  • 4-space indentation: Makes nesting more prominent for users who prefer wider indentation.
  • Compact JSON: Removes unnecessary whitespace and line breaks for certain data transfer scenarios.

Formatting should only change the presentation of JSON, not property names, array order or data types.

Common YAML Parsing Errors

1. Incorrect YAML Indentation

YAML uses indentation to express hierarchy, normally with spaces rather than tabs. Inconsistent indentation can cause parsing failures.

2. Missing Space After a Colon

Common YAML key-value mappings should use syntax such as name: Tom. Without the separating space, the content may be interpreted as a plain string.

3. Unclosed Quotation Marks

For example, name: "Tom is missing a closing quotation mark and may cause a parsing error.

4. Inconsistent List Indentation

Array items should generally use consistent indentation levels. Otherwise, the resulting structure may be invalid or unexpected.

5. Duplicate Property Names

Repeated keys at the same mapping level can create ambiguity. Check and correct duplicate keys to avoid overwritten data.

6. Unexpected YAML Data Types

Unquoted true, false, null or numeric values may be recognized as non-string types. Use quotation marks when a value must remain text.

Can YAML Anchors and Aliases Be Converted to JSON?

YAML supports anchors and aliases to reuse data, such as &defaults and *defaults. JSON has no equivalent anchor or alias syntax, so references usually need to be resolved into ordinary JSON structures.

For example:

defaults: &defaults
  timeout: 30
service:
  config: *defaults

When supported by the parser, the result can be:

{
  "defaults": {
    "timeout": 30
  },
  "service": {
    "config": {
      "timeout": 30
    }
  }
}

Cyclic aliases, excessive nesting or large alias expansions may not be safely representable as JSON. A converter should limit resource consumption or explicitly reject such structures.

YAML to JSON vs. JSON to YAML

FeatureYAML to JSONJSON to YAML
Input formatYAMLJSON
Output formatJSONYAML
Main purposeConvert configuration data for applicationsGenerate readable configuration data
ArraysYAML lists become JSON arraysJSON arrays become YAML lists
Data typesRecognized according to parser rulesYAML scalars generated from JSON types
Multiple documentsMultiple-document handling optionsUsually outputs one YAML document
FormattingJSON formatting and indentationYAML indentation, quotes and array styles

NZTool combines both directions in one interface. Because YAML supports comments, anchors, aliases and multiple documents, converting to JSON may lose information needed to reproduce the original YAML text exactly.

Common Uses for YAML to JSON

  • Kubernetes configurations: Convert Kubernetes YAML manifests into JSON for application processing and debugging.
  • Docker Compose: Convert YAML configurations to JSON to inspect structures or process them programmatically.
  • CI/CD analysis: Transform build and deployment configurations into JSON data.
  • API development: Convert YAML into JSON for API testing and data exchange.
  • Configuration migration: Organize YAML objects, arrays and primitive values into JSON.
  • Learning data formats: Compare YAML indentation and lists with JSON objects and arrays.

Frequently Asked Questions

Can YAML be converted directly to JSON?

Yes. Paste valid YAML, select YAML → JSON mode and run the conversion to generate JSON.

Do I need to install software?

No. NZTool parses and converts data locally in your browser.

Does YAML to JSON support nested objects?

Yes. Nested YAML mappings can become nested JSON objects.

Do YAML lists become JSON arrays?

Yes. YAML lists generally become JSON arrays while preserving item order.

Are multiple YAML documents supported?

Yes. You can convert multiple YAML documents into a JSON array or choose to report an error when multiple documents are present.

Are numbers and booleans preserved?

The tool offers number and boolean recognition options. Results depend on scalar values, quotation marks and parser settings.

Are YAML comments preserved?

No. Standard JSON does not support comments, so YAML comments are normally omitted.

Are YAML anchors and aliases preserved?

JSON has no anchor or alias syntax. Supported references are usually expanded into ordinary structures, while cyclic or complex references may not be representable.

Can the original YAML be restored from JSON?

Not necessarily. Comments, formatting, anchor names, quotation styles and document boundaries may be lost, so lossless round trips are not guaranteed.

Does YAML to JSON support Chinese text?

Yes. Both YAML and JSON support Unicode text, including Chinese, Japanese and other languages.

Why does YAML to JSON show an error?

Common causes include incorrect indentation, unclosed quotes, incorrect colon usage, malformed lists and unsupported YAML syntax. Review the error message and the corresponding input.

Can I format the JSON result?

Yes. JSON formatting and indentation options make results easier to read, copy and debug.

Can I download the JSON file?

Yes. Copy the converted JSON or use Download to save it.

Is YAML uploaded to a server?

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

Free Online YAML to JSON Converter

NZTool YAML to JSON converts YAML objects, arrays, nested configurations, multiline strings and multiple documents into JSON. Configure number, boolean and null recognition, JSON formatting, indentation and multiple-document handling. Reverse JSON to YAML conversion is also available. Everything runs locally in your browser without installation.
  • YAML to JSON: Paste YAML text and quickly generate structured JSON.
  • Objects and arrays: Convert nested mappings, lists and common scalar values.
  • Type recognition: Configure number, boolean and null parsing.
  • Multiline strings: Convert YAML block text into JSON strings.
  • Multiple documents: Convert YAML documents to a JSON array or report an error.
  • JSON formatting: Enable pretty printing with 2- or 4-space indentation.
  • Two-way conversion: Convert JSON to YAML, copy results and download files.
  • Local processing: No server uploads, ideal for configuration and API data.
Use NZTool YAML to JSON to convert configuration files, deployment manifests and structured data into application-friendly JSON for Kubernetes, Docker Compose, CI/CD and API development. Check indentation, duplicate keys, quotation marks and types before conversion, then verify object nesting, array order and field values. YAML comments, anchor names and original formatting generally cannot be fully preserved in JSON.
Comments 0
No comments yet. Be the first to comment!
avatar
Comment content cannot be empty
0/255