Skip to main content

JSON to YAML and YAML to JSON converter

Switch quickly between JSON and YAML structures and get formatted output ready to copy or reuse in your project.

  • Clipboard
  • Export
Automate

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Was this tool useful?

How does this tool work?

Convert JSON structures to YAML for readable configuration, or YAML to JSON for an API or your JSON tools. The converter retains nested objects, lists, booleans, strings, representable numbers and null values. It parses the source structure before serializing the target rather than replacing separators. Everything runs in your browser; no remote conversion service receives your configuration. Choose the direction explicitly whenever the source text could belong to either format.

Automatic mode reads input starting with { or [ as JSON and other input as YAML. This shortcut cannot determine every intention: JSON overlaps with many YAML forms. Select JSON to YAML for a standalone JSON scalar, or YAML to JSON for a YAML flow mapping in braces.

YAML conversion uses version 1.2 with the core schema. Objects and lists are rebuilt recursively. Mapping keys must be strings, just like JSON property names. Duplicate keys, multiple documents, custom tags, nonfinite numbers and cyclic aliases are rejected rather than discarded or flattened. Ordinary aliases expand under a bounded expansion limit; structures deeper than 128 levels are also rejected.

Integers outside JavaScript’s safe range cause a conversion error. This prevents exporting identifiers that were silently rounded. Put those identifiers in quotes in the source. Decimal values remain subject to the browser’s numeric representation; this is not an arbitrary-precision decimal converter.

YAML comments, anchor names and quotation choices have no direct JSON equivalent and are not retained through conversion. Use YAML Formatter when you want to reindent YAML while retaining documentary presentation. A round trip concerns compatible values, not original bytes or layout.

How to use this tool

  1. Select the appropriate direction

    Use an explicit mode to resolve detection ambiguity. YAML to JSON can read a compact YAML mapping starting with an opening brace.

  2. Paste one complete document

    Import or paste a single structure and convert it. Fix syntax errors, duplicate keys or unrepresentable values when conversion is rejected.

  3. Check types and export

    Inspect strings resembling numbers and nested lists. Downloads use the resulting format’s extension and media type. Editing the source or direction hides the previous result.

Use cases

Prepare a configuration excerpt

Turn a JSON object into consistently indented YAML. Ambiguous strings such as "true" and "01" remain distinct from booleans and numbers.

Inspect YAML with JSON tools

Produce objects and arrays for JSON formatting or supported JSON Schema checks. Conversion does not verify Kubernetes, application or API-specific rules.

Identify an incompatible structure

A non-string key or cyclic alias exposes a real difference between the models. Adapt that data explicitly instead of relying on silent deletion.

Examples

JSON to YAML with ambiguous strings

active stays boolean. Quotation marks keep number and yes as strings; the list contains an object followed by null, while the empty object remains representable.

Input

{"active":true,"number":"01","yes":"true","rows":[{"id":1},null],"empty":{}}

Result

active: true
number: "01"
yes: "true"
rows:
  - id: 1
  - null
empty: {}

YAML to JSON with an object and list

user becomes an object and tags an array. code keeps "01" as a string without becoming a number or losing its leading zero.

Input

user:
  name: Ada
  active: true
tags:
  - api
  - test
code: "01"

Result

{
  "user": {
    "name": "Ada",
    "active": true
  },
  "tags": [
    "api",
    "test"
  ],
  "code": "01"
}

Tips and best practices

  • Quote identifiers with leading zeros or very large integer values; identifiers usually are not intended for arithmetic.
  • Keep the annotated YAML source: JSON cannot transport its comments and conversion back cannot reconstruct them.
  • Split files containing several documents separated by --- before conversion. This interface produces one target document.
  • Conversion stays local, but configuration may contain secrets. Review the text before placing it in shared documentation.

Sources and references

Frequently asked questions

Why choose a direction when automatic detection is available?

Input beginning with { or [ might also be YAML, and scalar values can belong to both formats. Explicit mode states your intention without modifying the document to work around detection.

Will YAML comments and anchors survive?

Comments have no JSON representation. Compatible aliases expand to values; their names and shared identity are lost. YAML Formatter is better suited to retaining an annotated YAML document.

Why are some numbers or mapping keys rejected?

JSON requires string keys and cannot represent infinite values. The converter also rejects unsafe integers instead of exporting a silent approximation. Use strings when that matches your data contract.

Does conversion validate my configuration file?

It checks syntax and whether values can be represented in the target format. It does not certify an application schema, deployment configuration or the suitability of chosen settings.

Related tools

Tools similar or complementary to this one.

Similar tools

Format and validate a YAML document to improve readability and detect common errors.

DevelopmentUse this tool

Format, minify, and validate JSON to make it easier to read or more compact.

DevelopmentFeaturedUse this tool

Validate a JSON document against a schema and locate every error precisely.

DevelopmentFeaturedUse this tool