JSONGenerator
GeneratorSchemaConvertersExamplesDocs

JSONGenerator

Free online tools for generating random JSON data and JSON Schemas.

Quick Links

  • JSON Generator
  • JSON Schema Converter
  • Examples
  • Docs
  • Blog
  • About
  • Contact
  • Privacy Policy

Converters

  • JSON to YAML
  • YAML to JSON
  • XML to JSON
  • JSON to XML
  • JSON to TOML
  • TOML to JSON
  • JSON to CSV
  • CSV to JSON
  • JSON to Excel
  • Excel to JSON
  • JSON to HTML table
  • JSON to TypeScript
  • JSON to C#
  • JSON to Go
  • JSON to Java
  • JSON to SQL

Support

Having issues? Contact us.

© 2026 JSON Generator. All rights reserved.

YAML to JSON Converter

Paste YAML or drop a .yaml file and convert it to formatted JSON as you type.

Swap directionSwap direction

YAML Input

Paste YAML, upload a .yaml or .yml file or drop one here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Deployment config with shared defaults
defaults: &defaults
  replicas: 2
  region: NO
  enabled: yes

service:
  <<: *defaults
  name: orders-api
  image: ghcr.io/acme/orders:1.10
  ports: [80, 443]
  env:
    - name: LOG_LEVEL
      value: info
  description: |
    Handles order intake
    and fulfilment events.
  released: 2024-01-15
---
# A second document: the output becomes an array
service: billing-api
replicas: 1

JSON Output

Updates as you type. Copy it or download a .json file.

1

Converting…

Convert YAML to JSON online

This free YAML to JSON converter turns a YAML document into formatted JSON that you can paste into an API client, a test fixture or a script. Paste your text, or open a .yaml or .yml file, and the JSON appears as you type. Nothing to install, no sign-up, and your data stays in your browser instead of being uploaded.

It is built for the files developers actually have: Kubernetes manifests, Docker Compose and GitHub Actions workflows, OpenAPI specs and application config. Anchors, aliases and merge keys are resolved, files with several --- documents are supported, and a syntax error is reported with its line and column rather than a blank output.

How to convert YAML to JSON

  1. Paste your YAML into the YAML Input editor, or click the upload button to open a .yaml or .yml file. You can also drag a file onto the editor.
  2. The JSON Output updates as you type. If the YAML is invalid, the status bar shows what is wrong and where, for example at line 4, column 4.
  3. Optionally choose 2 spaces, 4 spaces or Minified output, or tick Read as YAML 1.1 if your file relies on yes and no being booleans.
  4. Click Copy to put the JSON on your clipboard, or Download to save it as data.json.

YAML to JSON example

Mappings become objects, sequences become arrays, and the | block keeps its line breaks. The merge key << copies the defaults into service, and the country code NO stays the string "NO". The comment is not part of the output because JSON has no comments.

YAML input
# Shared defaults
defaults: &defaults
  replicas: 2
  region: NO

service:
  <<: *defaults
  name: orders-api
  ports: [80, 443]
  debug: false
  motd: |
    Welcome
    back
JSON output
{
  "defaults": {
    "replicas": 2,
    "region": "NO"
  },
  "service": {
    "replicas": 2,
    "region": "NO",
    "name": "orders-api",
    "ports": [
      80,
      443
    ],
    "debug": false,
    "motd": "Welcome\nback\n"
  }
}

How YAML maps to JSON

YAML constructs and the JSON this converter produces
YAMLJSON outputNotes
MappingObjectKeys stay in the order they appear.
SequenceArrayBoth - item lists and [a, b] flow style.
Plain, quoted and block stringsStringBlock scalars | and > keep or fold line breaks.
Integers and floatsNumber0x1F becomes 31 and 1e3 becomes 1000.
true / falseBooleanyes, no, on and off stay strings unless YAML 1.1 is ticked.
null, ~nullA key with no value is null too.
Dates and timestampsStringWritten exactly as they appear in the YAML.
Anchors, aliases, merge keysExpanded copiesJSON has no references, so the data is repeated.
Several --- documentsArrayOne element per document.
CommentsDroppedJSON cannot hold comments.

Anchors, aliases and merge keys

An anchor (&defaults) names a value and an alias (*defaults) reuses it. The converter replaces every alias with a full copy of the anchored value. The merge key << works the same way for mappings: it can take one alias or a list of them, and keys you write directly under it override the merged ones. A file that refers to an anchor that does not exist, or an anchor that contains itself, is rejected with an error. So is one that expands into an unreasonable number of copies, which is how a "billion laughs" file would hang a parser.

Files with multiple YAML documents

Kubernetes and Helm output often put several resources in one file, separated by ---. JSON allows only a single top-level value, so the converter wraps the documents in an array. A file with one document, including one that starts with a --- line, is not wrapped. Empty documents are skipped, so a trailing separator does not add a null.

YAML input
kind: Service
---
kind: Deployment
JSON output
[
  {
    "kind": "Service"
  },
  {
    "kind": "Deployment"
  }
]

YAML 1.2 or YAML 1.1: yes, no, on and off

By default the file is read as YAML 1.2, the current version, where only true and false are booleans. That means enabled: yes becomes the string "yes" and a country code like NO stays text. Many tools still follow YAML 1.1, including PyYAML and the parsers behind Kubernetes and Ansible, where yes, no, on, off and a lone y or n are booleans. If your file was written for one of those tools, tick Read as YAML 1.1. That mode also reads values like 1:30 as numbers (90), and turns dates into full ISO timestamps.

Dates, timestamps and big numbers

In YAML 1.2, a value like 2024-01-15 is just a string, and it stays one in the JSON. Only an explicit !!timestamp tag, or YAML 1.1 mode, converts it into an ISO 8601 string such as 2024-01-15T00:00:00.000Z. Integers larger than 253 keep all their digits instead of being rounded the way a JavaScript number would be. YAML's .inf and .nan have no JSON equivalent and become null.

Non-string keys and YAML-only types

JSON object keys are always strings, so a key like 1, true or null is written as "1", "true" or "null". A key that is itself a list or mapping becomes its compact JSON text. Tagged values are converted too: !!binary becomes a base64 string, !!set becomes an array and !!omap becomes an object. Custom tags such as CloudFormation's !Ref are ignored and the value underneath is kept, so !Ref MyBucket turns into "MyBucket".

Duplicate keys and syntax errors

A mapping that repeats a key is reported as an error instead of silently keeping the last value, because that is almost always a mistake in the file. Other problems, such as a tab used for indentation, an unclosed bracket or a stray colon, are reported with the line and column from the top of your input, including in later documents of a multi-document file.

Why convert YAML to JSON?

  • Calling APIs: Most HTTP APIs and client libraries expect JSON bodies, even when the config you started from is YAML.
  • Kubernetes and Helm: Turn a manifest into JSON for kubectl, a JSON Patch, or a script that processes resources with jq.
  • OpenAPI and Swagger: Specs are often written in YAML, but some tools and gateways only import JSON.
  • Validation and tests: JSON Schema validators, test fixtures and mock servers all take JSON, so convert the YAML once and reuse it.
  • Checking what a YAML file really means: Expanding anchors and showing how values are typed is a quick way to debug a config that behaves oddly.

Need the opposite direction? The JSON to YAML converter turns JSON back into readable YAML. If you work with other config formats, there is also a TOML to JSON converter and an XML to JSON converter, and the JSON to TypeScript converter can generate types from the result. To check the converted data against a contract, build a schema with the JSON Schema generator, or create test data with the JSON Generator. For a longer look at the trade-offs between the two formats, read YAML vs JSON.

Frequently Asked Questions

How do I convert YAML to JSON?

Paste your YAML into the YAML Input editor, or upload a .yaml or .yml file. The JSON appears in the output editor as you type. Copy it, or click Download to save it as data.json.

Is YAML a superset of JSON?

Nearly. YAML 1.2 was designed so that valid JSON is also valid YAML, which is why this converter accepts JSON as input. The reverse is not true: comments, anchors, multiple documents and non-string keys have no JSON equivalent, so the converter drops or rewrites them.

What happens to YAML files with several documents?

A file with one document becomes that document's JSON value. A file with several documents separated by --- becomes a JSON array with one element per document, because a JSON file can only hold one value. Empty documents, such as one left by a trailing ---, are skipped.

Does the converter support anchors, aliases and merge keys?

Yes. Aliases (*name) are replaced with a copy of the anchored value (&name), and merge keys (<<) are expanded into the surrounding mapping, with keys written locally taking priority. JSON has no references, so the output contains the full data.

Why does yes, no or NO stay a string instead of becoming true or false?

The converter reads YAML 1.2, where only true and false are booleans. Older YAML 1.1 parsers, such as PyYAML, also treat yes, no, on and off as booleans. If your file was written for one of those, tick Read as YAML 1.1 to get the same result.

Is my YAML uploaded to a server?

No. The conversion runs entirely in your browser with JavaScript, so your data never leaves your device. That makes it safe to use with config files that contain internal hostnames or other private values.

Can I convert JSON back to YAML?

Yes. Use the JSON to YAML converter, or click Swap direction above the editors. Converting YAML to JSON and back keeps the data, although comments and anchors are lost along the way.

Related converters

  • JSON to YAML ConverterConvert JSON to clean, readable YAML for config files, Kubernetes and CI pipelines.
  • XML to JSON ConverterConvert XML to JSON with attributes, repeated elements and text nodes mapped predictably.
  • JSON to XML ConverterConvert JSON to well-formed XML with a root element of your choice.
  • JSON to TOML ConverterConvert JSON to TOML for Cargo, pyproject and other config files.
  • TOML to JSON ConverterConvert TOML tables, arrays of tables and dates to JSON.
  • JSON to CSV ConverterConvert a JSON array to CSV, with nested objects flattened into columns.

See all JSON converters