Skip to content

YAML to JSON converter

YAML to JSON runs through our table engine, resolving anchors and aliases while writing JSON-safe values.

  • Converted with Table engine · nothing stored
  • Free: 5 conversions a day · 5 MB each
  • Higher limits →

From real runs

What you get — and what changes

  • Mappings and sequences Kept

    YAML objects and lists become JSON objects and arrays with the same data shape.

  • Anchors and aliases Changed

    Anchors and aliases are resolved so the JSON contains repeated concrete values instead of YAML references.

  • Comments Lost

    Comments are discarded because JSON has no standard comment syntax.

  • Multi-document YAML Changed

    A stream separated by --- becomes a JSON array of documents in order.

  • Dates Changed

    Date-looking values are emitted as strings to avoid timezone surprises in JSON consumers.

  • YAML 1.2 booleans Changed

    true and false become booleans; yes and no stay strings under YAML 1.2 semantics.

  • Tags Lost

    Custom YAML tags are not preserved as executable constructors in the JSON output.

Sample conversions

Anchored deployment config

Input
YAML: defaults: &defaults {retries: 3, region: us-east}\njob: {<<: *defaults, name: import}
Output
JSON resolves the alias: {"defaults":{"retries":3,"region":"us-east"},"job":{"retries":3,"region":"us-east","name":"import"}}.

Multi-document stream

Input
---\nname: first\n---\nname: second\nactive: true
Output
JSON: [{"name":"first"},{"name":"second","active":true}].

YAML 1.2 booleans

Input
YAML: answer: yes\nflag: true\ndate: 2026-09-10
Output
JSON: {"answer":"yes","flag":true,"date":"2026-09-10"}; yes is not a boolean.

A real YAML → JSON run

We converted our YAML sample (423 B) with Table engine on 2026-09-11. It took 1 ms and produced a 558 B JSON file, 1.3× larger than the input. The engine raised no warnings.

Input · sample.yaml · 423 B

4 list items, 0 top-level keys, 20 lines

List items
4
Top-level keys
0
Lines
20

Output · sample.json · 558 B

Array of 4 objects; keys: company, stage, arr, owner, close_date

Records
4
Keys
company, stage, arr, owner, close_date

First lines of the output

json
[
  {
    "company": "Northwind Traders",
    "stage": "Proposal",
    "arr": 48000,
    "owner": "R. Ayers",
    "close_date": "2026-10-14"
  },
  {
    "company": "Contoso Ltd",
    "stage": "Negotiation",
    "arr": 120000,
    "owner": "P. Ng",
    "close_date": "2026-09-30"
  },
  {
    "company": "Fabrikam",
    "stage": "Qualified",
…

Options and when to change them

multiDocument
Keep the default array output for YAML streams; reject multi-doc input only when your API expects one JSON object.
pretty
Pretty-print for review and code commits; compact output when payload size matters.
schema
Use YAML 1.2 semantics so yes/no stay strings; do not assume older YAML 1.1 booleans.

Do it yourself

yq

bash
yq -o=json '.' in.yaml > out.json

Check your yq implementation and version; Python yq and mikefarah/yq use different flags.

Python PyYAML

bash
python - <<'PY'
import json
import yaml
with open("in.yaml", encoding="utf-8") as fh:
    docs = list(yaml.safe_load_all(fh))
out = docs[0] if len(docs) == 1 else docs
with open("out.json", "w", encoding="utf-8") as fh:
    json.dump(out, fh, indent=2, ensure_ascii=False, default=str)
PY

PyYAML's scalar semantics may differ from strict YAML 1.2; verify yes/no and dates.

YAML to JSON by API or MCP

The HTTP API and the MCP server run the exact engine this page uses (Table engine); the response carries the same warnings the web converter shows. Check support first with GET /api/v1/pairs?from=yaml&to=json.

curl
curl -X POST https://filetypeconverters.com/api/v1/convert \
  -H "Authorization: Bearer $FTC_API_KEY" \
  -F "file=@input.yaml" -F "from=yaml" -F "to=json" \
  -F 'options={"encoding":"utf-8"}' \
  --output output.json

Options this engine accepts for YAML → JSON

KeyApplies toTypeDefault
encodingReading YAMLutf-8 · latin1utf-8
flattenSeparatorReading YAMLstring.
arrayModeReading YAMLjson · explodejson
delimiterWriting JSONstring,
newlineWriting JSON ·
sheetNameWriting JSONstring
dialectWriting JSONpostgres · mysql · sqlitepostgres
tableNameWriting JSONstringdata
createTableWriting JSONbooleantrue
API reference

When this is the wrong conversion

  • Do not convert YAML to JSON if comments are the important documentation; JSON will drop them.
  • If custom YAML tags drive application behavior, use your application's YAML parser instead of a generic converter.
  • For Kubernetes patches where anchors are not accepted anyway, validate the resulting JSON against the target schema.

YAML to JSON questions

Are YAML anchors preserved in JSON?

No. Anchors and aliases are resolved into ordinary JSON values because JSON has no anchor reference syntax.

Do YAML comments appear in the JSON output?

No. Comments are lost during conversion. Copy them into separate documentation if they need to survive.

Does yes become true?

No. Under YAML 1.2 semantics, yes and no are strings. Only true and false become booleans.