FIRST CH TOOLS / 20 JSON ⇄ YAML

JSON ⇄ YAML Converter & Syntax Formatter

Paste into either box and it is converted to the other format as you type. Pick the indent width and quoting style to reformat, and syntax errors are pinpointed by line and column with an explanation of what is wrong. Made for reading docker-compose and GitHub Actions config the other way round, and for turning API responses into config files.

Type in either box and the other one follows

JSON
YAML
0
Input bytes
0
Output bytes
0
Keys
0
Deepest nesting
Syntax check

    Nothing you paste leaves the browser — the YAML parser and writer are implemented on this page, with no external library. Loading a file only reads it locally; it is never uploaded. Directly callable via URL parameters: /en/json-yaml/?yaml=a%3A%201 / /en/json-yaml/?json=%7B%22a%22%3A1%7D&indent=4

    How to Use

    1. Paste into either boxJSON on the left produces YAML on the right, and YAML on the right produces JSON on the left. You can also drag a config file onto either box.
    2. Choose the formattingSwitch the indent width, the quoting style and the key order. To tidy a file up without changing format, press "Format" above that box.
    3. Check the result and copySyntax errors are shown with their line and column. Anything whose meaning may change — tab indentation, 0755, yes, duplicate keys — appears in the warnings.

    About This Tool

    JSON and YAML describe the same data structures — mappings, sequences and scalars — with different notation. JSON marks structure with brackets and quotes, which suits machines; YAML marks it with indentation, which suits people. Config files gravitate to YAML while APIs speak JSON, and the boundary between them is where you need to convert.

    YAML is a superset of JSON, so any valid JSON is already valid YAML (flow style is exactly JSON's notation). The reverse is not true. YAML has comments, anchors, multiple documents and timestamps with no JSON counterpart, so converting YAML to JSON always loses something. Rather than dropping those quietly, this tool reports them: comments removed, aliases expanded, multiple documents merged into an array.

    Syntax errors come with a line and a column. The message from the browser's own JSON.parse differs between engines, and so does the way the position is reported. Here both JSON and YAML are parsed by hand, so every browser shows the same position and the same explanation. Two lines either side of the error are quoted, with ^ marking the column.

    YAML has an unusual number of ways to parse fine but mean something else. Tab indentation, 0755 becoming decimal 755, yes and NO becoming booleans (the Norway problem), 12:30 becoming 750 in base 60, duplicate keys silently overwriting each other — the tool raises all of these every time it converts. The "YAML pitfalls" tab collects them with examples.

    It also reads the JSON people actually have. JSON with comments (as in tsconfig.json), JSON with a trailing comma, JSON with single quotes or unquoted keys — all are read and converted, with a note that they are not valid JSON. Telling you what to fix is more useful than refusing to parse.

    When writing YAML, the tool picks forms that cannot change meaning. Strings that another parser could read as a different type — yes, 0755, 12:30, 2026-08-12 — plus strings with leading or trailing spaces and strings starting with - or * are quoted automatically. Strings containing newlines become | blocks, unless the exact text could not be restored that way (trailing spaces on a line, for instance), in which case they fall back to "…".

    Numbers are handled as double-precision floats. Integers are exact up to 2^53 (about 9.007 quadrillion); beyond that the low digits change, so those values are flagged. .inf and .nan do not exist in JSON and become null.

    From AI Agents

    This conversion logic is also available as the json_to_yaml and yaml_to_json tools of the MCP (Model Context Protocol) server @first-ch/tools-mcp, so an AI agent can call it directly without a browser — including reading and writing files by path. See Using these tools from AI agents for setup details.

    Setup

    claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp

    Examples

    # JSON to YAML (indent 2, quotes only where needed)
    json_to_yaml(text='{"name":"web","ports":["80:80"]}')
    
    # YAML to JSON, minified
    yaml_to_json(text="name: web\nports: [80:80]", indent=0)
    
    # Read a config file, convert it, write it somewhere else
    json_to_yaml(path="/tmp/config.json", outputPath="/tmp/config.yaml", indent=4)
    
    # Just check the syntax (returns the error line/column and any warnings)
    yaml_to_json(path="/tmp/docker-compose.yml")

    Other Tools