YAML JSON Converter

Convert YAML to JSON and back online, with three directions, indent options and key sorting. Syntax errors report the exact line and column, all locally.

Sorting

How to use

  1. Pick a direction in the dropdown: YAML to JSON, JSON to YAML, or YAML to YAML (normalize).
  2. Paste your content into the input box, choose 2 or 4 space indent, and tick Sort keys to order fields alphabetically.
  3. Press Convert. The result appears in the output area below; press Copy result to take it away.
  4. If the conversion fails, the error names the line and column. Fix the source and convert again.

FAQ

Is my data processed on a server?
No. Parsing and generation run locally through the js-yaml library inside your browser. Input and output never leave the page, and a loaded page keeps working offline.
Why did my date become a string?
The tool reads YAML with JSON_SCHEMA, so dates stay plain strings instead of date objects. Types therefore remain stable when the result is written back to JSON or YAML.
Can I convert several YAML documents at once?
No. A stream separated by triple dashes raises an error. Split the file at the separators and convert each part on its own.
Why is the result not wrapped?
Output never wraps, so long strings and URLs stay on one line. Pasting the result into another editor and parsing it again introduces no ambiguity, and it is easier to read directly.

How to use

  1. Choose the direction

    Pick YAML to JSON, JSON to YAML or YAML to YAML in the dropdown. The third option re-indents the document with the current options, which suits style checks and syntax checks.

  2. Paste your text

    Paste the YAML or JSON into the input box. A wrong direction is not a problem: the tool validates the content first and reports what went wrong when the format does not match.

  3. Adjust the output

    Choose 2 or 4 space indent. Tick sort keys to reorder the fields of every object alphabetically, which makes comparing two config files much easier.

  4. Convert and copy

    Press Convert and the result appears in the output area below. Use Copy result to take it away, or press Load sample first to try the tool with ready-made data.

About this tool

This tool converts between YAML and JSON entirely in your browser. Parsing and generation run through the open-source js-yaml library on your own device, so the text you paste never reaches a server. Three directions are available. YAML to JSON prints indented JSON, JSON to YAML prints a clean YAML document, and YAML to YAML re-indents the input with the current options. Indent can be 2 or 4 spaces, output never wraps, and long strings or URLs stay on one line. When conversion fails, the page points at the line and column of the problem, so a fix usually takes seconds.

YAML loading uses the JSON_SCHEMA of js-yaml. In this mode date and time values stay plain strings, and numbers are limited to integers and floats. One file therefore cannot turn into different types under different settings. Booleans, null, nested objects and arrays all map cleanly onto the JSON model, and keys and string values are preserved as written. Config files, API samples and deployment manifests often need to move between the two formats. Paste, convert and copy, with no editor plugin or command line tool required, and it works on a phone browser too.

How it works

YAML and JSON share one data model: objects, arrays, strings, numbers, booleans and null. Conversion runs in two steps. The input is first read into an in-memory data structure, then written out in the target format. The data itself survives a round trip unchanged; only layout and quoting style move. The default js-yaml mode turns 2024-01-01 into a date object, and date objects do not travel well between languages. This tool fixes the schema to JSON_SCHEMA, so dates and times stay plain strings and never become unexpected types in JSON. Many config parsers make the same safe choice.

Error locations come from the mark data that js-yaml attaches to its exceptions. A failed parse raises an object carrying the line and column of the problem. The library counts from zero, so the page adds one to both numbers before showing them. The JSON side is checked by a small syntax scanner before parsing, and it reports the line and column of the first broken token. Both sides therefore report locations the same way. Among the output options, indent sets the spaces per level. Sort keys orders every object alphabetically before writing. The no-wrap setting keeps long strings on a single line, so pasted results keep their meaning.

When to use it

  1. Move config between formats

    A project you just inherited keeps its settings in JSON while the team standard asks for YAML. Paste the file, convert it once and the field hierarchy survives untouched. Output with 2 space indent, drop it into the repository and the review passes without another formatting round.

  2. Build samples for docs

    API documentation needs tidy YAML examples. Express the data as JSON first, convert it, and sort keys so the structure stays stable. Later edits then produce clean diffs, and readers can map each field to the request payload without extra work.

  3. Track down YAML errors

    A deploy tool complains about YAML syntax but the message stays vague. Paste the snippet here and convert once. The error carries a line and column, so tab indentation, missing spaces or dropped colons are usually located on the first try.

Tips & tricks

  • Match the indent to the target project first: Kubernetes manifests usually use 2 spaces, while some team standards ask for 4.
  • Start at the reported line and column when an error appears. The real problem is often at the end of the previous line, such as a missing space after a colon.
  • Tick sort keys before diffing two config files. Once the field order matches, real differences stand out immediately.

Things to watch

  • Tabs are not valid indent

    YAML forbids tab characters for indentation and allows spaces only. Config copied from chat windows or PDFs often carries tabs along. When an error points at a line, check the line start first and replace every tab with spaces, then convert again.

  • Anchors expand in JSON

    YAML anchors and references are a syntax level reuse feature. Converting to JSON expands them into full copies. A large file can therefore produce a much longer output, which is normal. The data has not multiplied and the conversion has not gone wrong.

  • Only the first document

    A file separated into several YAML documents by triple dashes is parsed as one stream and the tool reports an error. Split the file at the separators first, paste each part on its own, and convert the parts one by one.

Related Tools