JSON ⇄ YAML Converter

Bidirectional conversion between JSON and YAML with advanced formatting options

Input & Settings

JSON → YAML
2 spaces
80 chars

YAML Output

Converted data will appear here

Analysis & Stats

Conversion statistics will appear here

JSON
Compact, machine-readable
YAML
Human-readable, configuration

Format Examples & Use Cases

JSON Format

Compact, machine-readable data interchange format.

{
  "server": {
    "host": "localhost",
    "port": 8080,
    "ssl": true
  },
  "database": {
    "url": "mongodb://localhost",
    "name": "myapp"
  }
}

YAML Format

Human-readable, great for configuration files.

server:
  host: localhost
  port: 8080
  ssl: true

database:
  url: mongodb://localhost
  name: myapp

    Examples

    Convert a nested server object

    Input
    {"server":{"host":"localhost","ports":[80,443],"tls":true}}
    Output
    server:
      host: localhost
      ports:
        - 80
        - 443
      tls: true

    With the default two-space indentation, the nested object becomes a block mapping and its ports array becomes a block sequence.

    Convert an array and scalar together

    Input
    {"languages":["JavaScript","Python","Go"],"count":3}
    Output
    languages:
      - JavaScript
      - Python
      - Go
    count: 3

    Array order is preserved, and the numeric count remains an unquoted number.

    Convert an array of objects

    Input
    {"users":[{"id":1,"name":"Ada"},{"id":2,"name":"Linus"}],"active":true}
    Output
    users:
      - id: 1
        name: Ada
      - id: 2
        name: Linus
    active: true

    Each JSON object becomes one mapping item in the YAML sequence.

    About this tool

    The JSON ⇄ YAML Converter transforms structured data in both directions. In JSON-to-YAML mode it parses the input with JSON.parse and serializes the resulting value with js-yaml; in YAML-to-JSON mode it loads YAML with js-yaml and emits indented JSON. Objects become mappings, arrays become sequences, and JSON strings, numbers, booleans, and null retain their data roles through the conversion.

    YAML output can be tuned with an indent width from 1 to 8 spaces, a line width from 40 to 200 characters, natural or sorted keys, automatic, single, or double quote style, and reference suppression. The reverse mode uses the selected indent width for pretty-printed JSON. Built-in samples and text-file upload make it easy to start with an existing payload.

    The result can be copied or downloaded as .yaml or .json, while the analysis panel reports line count, byte sizes, size ratio, processing time, format, and active formatting choices. Conversion happens in the browser, and parse errors are shown instead of producing an incomplete result.

    How to use

    1. Choose a conversion direction

      Start in JSON → YAML mode, or use the mode switch for YAML → JSON. When a result already exists, switching modes moves that result into the input so you can convert it back.

    2. Enter or load structured data

      Paste text into the input editor, choose one of the quick samples, or load a .json, .yaml, .yml, or .txt file appropriate to the selected direction.

    3. Set the output formatting

      For YAML, choose indentation, line width, quote style, key sorting, and whether references are suppressed. For JSON, choose the pretty-print indentation width.

    4. Convert and export

      Click Convert, inspect any parse error and the optional statistics, then copy the complete output or download it with the matching file extension.

    Use cases

    Creating configuration files

    Turn a JSON settings object into readable YAML for tools that use .yaml or .yml configuration files.

    Moving data between APIs and infrastructure

    Convert JSON API examples into YAML documentation or translate YAML configuration back into JSON for a service that expects application/json.

    Reviewing deeply nested payloads

    Use block-style YAML and adjustable indentation to make nested objects and arrays easier to scan during debugging or code review.

    Normalizing generated files

    Sort mapping keys, choose an indentation width, and download consistent YAML output for fixtures, examples, or generated configuration.

    Common mistakes

    Mistake:Using tabs to indent YAML or mixing indentation widths within one structure.

    Fix:YAML structure is indentation-sensitive, and tabs are forbidden for indentation. Use spaces consistently; the converter defaults to two spaces and lets you select one to eight.

    Mistake:Leaving yes, no, on, off, or null unquoted when they must remain strings.

    Fix:Quote ambiguous scalar text explicitly. null resolves as a null value, and YAML 1.1 or schema-specific consumers may coerce yes/no/on/off to booleans even though YAML 1.2 core behavior differs.

    Mistake:Supplying duplicate keys and assuming every parser keeps the same value.

    Fix:Make every JSON object name and YAML mapping key unique before conversion. Duplicate-key behavior varies between parsers: values may be overwritten, rejected, or reported differently.

    Mistake:Confusing block collections with different data types than flow collections.

    Fix:`- item` and `[item]` are both YAML sequences, while indented `key: value` pairs and `{key: value}` are both mappings. The converter emits block style by default; flow style changes presentation, not the underlying array or object.

    Frequently asked questions

    References & standards