# JSON YAML converter

> Convert JSON, YAML, TOML, and XML in the browser, and keep the line number when a document fails.

Free converter for JSON to YAML, YAML to JSON, TOML, and XML to JSON. The source format can be detected automatically. Errors include a line and column. Conversion stays in the browser.

- Page: https://benchline.fabwaseem.com/t/json-yaml-convert
- Runs: in the browser. Input stays on the device.
- Price: free, no account
- Input: A JSON, YAML, TOML, or XML document, a source format, and a target format.
- Output: The document in the target format, or a line and column for the parse error.
- Keywords: json to yaml, yaml to json, xml to json, toml to json
- Updated: 2026-10-18
- Built by: Waseem Anjum (https://fabwaseem.com)

## How to use it

1. **Paste a document.** Leave the source on Auto, or choose JSON, YAML, TOML, or XML if the first line is ambiguous.
2. **Pick the target.** The other pane updates as you type. TOML refuses null and a root that is not a table.
3. **Copy or download.** A valid result can be copied or saved. An invalid one names the line and column.

## Use it from an AI agent

MCP tool name: `convert_data_format`
MCP endpoint: https://benchline.fabwaseem.com/mcp (Streamable HTTP, no key)
HTTP: POST https://benchline.fabwaseem.com/api/v1/tools/json-yaml-convert with the input as the JSON body
This call does not fetch anything. It runs on the arguments you send.

Convert between JSON, YAML, TOML, and XML. Auto-detects the source. Numbers that do not fit in a JavaScript number keep their digits. Errors include a line and column. TOML refuses null and a non-table root.

### Input schema

```json
{
  "type": "object",
  "properties": {
    "text": {
      "type": "string",
      "description": "The source document."
    },
    "from": {
      "default": "auto",
      "type": "string",
      "enum": [
        "auto",
        "json",
        "yaml",
        "toml",
        "xml"
      ]
    },
    "to": {
      "default": "json",
      "type": "string",
      "enum": [
        "json",
        "yaml",
        "toml",
        "xml"
      ]
    }
  },
  "required": [
    "text",
    "from",
    "to"
  ],
  "additionalProperties": false
}
```

### Example tools/call

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "convert_data_format",
    "arguments": {
      "text": "example",
      "from": "auto",
      "to": "json"
    }
  }
}
```

Setup for Claude, Cursor, and VS Code: https://benchline.fabwaseem.com/mcp/guide

## Questions

### Which direction does this convert?

Any of JSON, YAML, TOML, and XML can be the source or the target. Auto reads the first line and picks JSON, XML, TOML, or YAML.

### Is the conversion lossless?

JSON, YAML, TOML, and XML round-trip objects, arrays, strings, numbers, and booleans, including integers and decimals that do not fit in a JavaScript number. TOML has no null and no array or scalar at the document root, so those documents are refused instead of being dropped. XML attributes come back as @name and mixed text as #text.

### Why does yes stay a string?

YAML is read with the JSON schema, so yes, no, and dates stay strings. That keeps a config from changing type on the way to JSON.

### Where does the error line come from?

JSON, YAML, TOML, and XML parsers each report a line and column, counted from 1. The message is the parser's reason, not a guess.

## Related tools

- [JSON formatter](https://benchline.fabwaseem.com/t/json-formatter): Pretty-print, minify, and validate JSON, with the exact line and column when it fails.
- [CSV JSON converter](https://benchline.fabwaseem.com/t/csv-json-convert): Convert CSV to JSON and JSON back to CSV, with a delimiter and a header row you choose.
- [Diff checker](https://benchline.fabwaseem.com/t/diff-checker): Compare two texts side by side or inline, and download a unified patch.
- [Base64 codec](https://benchline.fabwaseem.com/t/base64-codec): Encode and decode Base64 for text or a file, including the URL-safe alphabet.
