# YAML to JSON Converter: JSON to YAML & Validator (`ucchiii/yaml-json-converter`) Actor

Convert YAML to JSON and JSON to YAML from pasted text, file URLs or key-value store records. Syntax errors are reported with line and column. Multi-document YAML, YAML lists to CSV, safe loading only. Empty input = free demo.

- **URL**: https://apify.com/ucchiii/yaml-json-converter.md
- **Developed by:** [Actor Factory](https://apify.com/ucchiii) (community)
- **Categories:** Developer tools, Automation, Integrations
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.42 / 1,000 converted documents

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**YAML to JSON converter (and JSON to YAML): paste text or give file links, get the converted text in the results plus a downloadable file — with syntax errors reported by line and column.**

Paste YAML or JSON, or list `.yaml`, `.yml`, `.json` or `.jsonl` file URLs (or records in a key-value store), press **Start**, and every document comes back converted. YAML with several documents (`---`), anchors and aliases (`&defaults`, `<<: *defaults`), dates and comments is handled; broken input gives a free error row that says exactly where the problem is. YAML is only ever read with the safe loader, so a file can never run code. You pay per converted document — no monthly rent.

**Try it free:** clear the input and press **Start** — a built-in sample config is converted to `sample-config.json` (not charged; rows carry `_demo: true`).

### What you get

Input (YAML):

```yaml
app:
  name: shop-api
  port: 8080
  allowed_origins:
    - https://example.com
```

Result row:

| status | source | document | direction | topLevelType | file | output |
|---|---|---|---|---|---|---|
| ok | inline text | 1 | yaml-to-json | object | inline.json | `{"app": {"name": "shop-api", "port": 8080, "allowed_origins": ["https://example.com"]}}` |

A syntax error instead gives:

| status | source | error | line | column |
|---|---|---|---|---|
| error | https://example.com/deploy.yaml | Invalid YAML: while parsing a flow sequence expected ',' or ']', but got ':' | 3 | 2 |

- **One result row per document**: converted text (first 100,000 characters), top-level type and size, file name and download link.
- **One output file per input** in the run's key-value store (`.json`, `.jsonl`, `.yaml` or `.csv`) with a signed download link.
- **Error rows** for invalid YAML or JSON, with the 1-based **line** and **column** and the document number — free.

### How to use

1. **YAML or JSON text** — paste it. **And/or** **file URLs** to public `.yaml`, `.yml`, `.json`, `.jsonl` or `.ndjson` files. **And/or** a **key-value store** with files as records.
2. **Conversion** — `auto` (default: YAML becomes JSON, JSON becomes YAML, decided by the file extension and then the content), or force `yaml-to-json`, `json-to-yaml` or `yaml-to-csv`.
3. Optional: **JSON indent** (0 = minified), **YAML indent**, **Sort keys**, how **several YAML documents** become JSON (one array or JSON Lines), **Formula-safe CSV**, whether to **save files** and to put the **converted text in the results**.

```json
{
  "fileUrls": ["https://example.com/k8s/deployment.yaml", "https://example.com/api/openapi.json"],
  "mode": "auto",
  "jsonIndent": 2
}
```

### Output details

- **YAML → JSON**: dates and timestamps become ISO text (`2026-03-02`, `2026-03-02T10:15:00+00:00`), `!!binary` becomes base64 text, sets become arrays, non-text keys become text (`1:` → `"1"`), `.nan` and `.inf` become `null` (JSON has no NaN; a note says so). Anchors and merge keys are expanded.
- **YAML 1.1 booleans**: like most YAML tools (PyYAML), unquoted `yes`, `no`, `on`, `off` are read as true/false — also as keys (`on:` → `"true"`). Quote them (`"on":`) to keep them as text.
- **JSON → YAML**: key order is kept (unless **Sort keys**), Unicode is written as is, long strings are not wrapped. JSON Lines files (`.jsonl`) become multi-document YAML separated by `---`.
- **Auto with text that starts with `{` or `[`**: it is treated as JSON, so a broken JSON gets a JSON error with its line and column. For YAML flow style like `{a: 1}` that is not JSON, choose `yaml-to-json`.
- **Duplicate keys** are allowed by YAML parsers (the last value wins); the Actor lists them in **notes** so you can fix them.
- **YAML → CSV**: a document that is a list of objects (or an object holding exactly one such list, like `items:`) becomes rows; columns are the union of keys in first-seen order; nested values are written as JSON text. All documents of one input go into one CSV.
- **Safety**: only standard YAML tags are read (safe loader). Python or custom tags such as `!!python/object` are refused with an error row. Inputs whose aliases would expand to more than 2,000,000 values (a "billion laughs" file) are refused.

### Limits (cannot be raised by input)

- **100 inputs** per run, each up to **10 MB** of UTF-8 (or UTF-16 with BOM) text, up to **10,000 documents** per input, output file up to **50 MB**.
- Public files only, no login. Links to internal network addresses are blocked.

### Pricing

Pay per event: **$0.0006 per converted document** ($0.60 per 1,000). A YAML file with 3 documents costs $0.0018. Syntax errors, failed downloads, inputs over a limit and the demo are free.
Store discounts apply automatically: BRONZE −10%, SILVER −20%, GOLD −30%.
If the maximum charge you set for the run is lower than the number of documents in an input, that input gets a free error row instead.

### FAQ

**Can I use it as a YAML validator?** Yes. Valid documents come back converted; invalid ones get an error row with the line, column and message, and are not charged.

**Does it keep comments?** No. Comments are not part of the YAML data model, so they are dropped when converting to JSON (and JSON has no comments).

**Kubernetes, Docker Compose, GitHub Actions, OpenAPI files?** Yes — they are plain YAML or JSON. Multi-document Kubernetes manifests become one JSON array (or JSON Lines).

**Can I call it from code?** Yes, through the Apify API: send `{"text": "..."}` and read the `output` field of the result rows.

If this Actor saved you time, a rating on the Store helps others find it.

### More tools from the same developer

- [JSON to CSV Converter](https://apify.com/ucchiii/json-to-csv) — turn nested JSON files or datasets into one flat CSV file
- [Flatten JSON to CSV](https://apify.com/ucchiii/flatten-json) — flatten nested JSON into flat rows with the separator you choose
- [Excel to JSON](https://apify.com/ucchiii/excel-to-json) — turn Excel (XLSX) sheets into JSON rows, or a JSON file into an Excel sheet
- [CSV to Excel Converter](https://apify.com/ucchiii/csv-xlsx-converter) — convert CSV, TSV, Excel XLSX, JSON and NDJSON files or Apify datasets into each other
- [Merge Datasets](https://apify.com/ucchiii/merge-datasets) — combine several datasets or CSV/JSON files into one, with columns aligned

# Actor input Schema

## `text` (type: `string`):

Paste YAML or JSON here (up to 10 MB). Several YAML documents separated by --- are fine. With mode 'auto', JSON becomes YAML and YAML becomes JSON. Leave this and the files empty for a free demo.

## `fileUrls` (type: `array`):

Public http(s) links to .yaml, .yml, .json, .jsonl or .ndjson files, up to 10 MB each and 100 inputs per run. Each file becomes one output file.

## `keyValueStoreId` (type: `string`):

Optional. ID or name of a key-value store that holds YAML or JSON files as records (for example files you uploaded in Apify Console). Converted after the text and URLs.

## `keyValueStoreKeys` (type: `array`):

Optional. Keys of the records to convert from the key-value store above, e.g. 'config.yaml'. Leave empty to convert every record in the store (except INPUT), up to 100.

## `mode` (type: `string`):

Auto: .yaml/.yml files and YAML text become JSON; .json/.jsonl files and JSON text become YAML. 'YAML list to CSV' turns a list of objects (or an object holding one list) into a CSV table.

## `jsonIndent` (type: `integer`):

Spaces per level in JSON output. 0 = minified on one line.

## `yamlIndent` (type: `integer`):

Spaces per level in YAML output.

## `sortKeys` (type: `boolean`):

Sort object keys alphabetically in the output. Off keeps the original order.

## `multiDocument` (type: `string`):

Only for YAML with several documents (separated by ---) converted to JSON. A single document is always plain JSON.

## `formulaSafe` (type: `boolean`):

YAML to CSV only: puts an apostrophe before text that starts with = + @ (or - when it is not a number), so Excel and Google Sheets never run it as a formula.

## `saveFiles` (type: `boolean`):

Save one converted file per input in the key-value store, with a download link in the results.

## `includeOutput` (type: `boolean`):

Put each converted document as text in its result row (first 100,000 characters; the file always has everything). Turn off for very large documents.

## Actor input object example

```json
{
  "text": "# Example: app settings\napp:\n  name: shop-api\n  port: 8080\n  debug: false\n  allowed_origins:\n    - https://example.com\n    - https://admin.example.com\ndatabase:\n  host: db.internal\n  pool_size: 10\n",
  "mode": "auto",
  "jsonIndent": 2,
  "yamlIndent": 2,
  "sortKeys": false,
  "multiDocument": "array",
  "formulaSafe": true,
  "saveFiles": true,
  "includeOutput": true
}
```

# Actor output Schema

## `results` (type: `string`):

One item per document: converted text, file name and download link, or the syntax error with line and column.

## `files` (type: `string`):

The key-value store that holds the converted .json, .yaml, .jsonl or .csv files.

## `stats` (type: `string`):

Record STATS: inputs converted and failed, documents converted and charged.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "text": `# Example: app settings
app:
  name: shop-api
  port: 8080
  debug: false
  allowed_origins:
    - https://example.com
    - https://admin.example.com
database:
  host: db.internal
  pool_size: 10`
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/yaml-json-converter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "text": """# Example: app settings
app:
  name: shop-api
  port: 8080
  debug: false
  allowed_origins:
    - https://example.com
    - https://admin.example.com
database:
  host: db.internal
  pool_size: 10
""" }

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/yaml-json-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "text": "# Example: app settings\\napp:\\n  name: shop-api\\n  port: 8080\\n  debug: false\\n  allowed_origins:\\n    - https://example.com\\n    - https://admin.example.com\\ndatabase:\\n  host: db.internal\\n  pool_size: 10\\n"
}' |
apify call ucchiii/yaml-json-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/yaml-json-converter"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/oxObX9iDpjLjtRZlO/builds/ibqmfZhqw7wLtmyrU/openapi.json
